main.dart 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:flutter_tracker/pages/welcome_page.dart';
  4. import 'package:flutter_tracker/routes/routes.dart';
  5. import 'package:flutter_tracker/utils/sp_util.dart';
  6. import 'index_page.dart';
  7. /// Description:
  8. /// Time : 2021年12月03日 Friday
  9. /// Author : liuyuqi.gov@msncn
  10. void main() async {
  11. WidgetsFlutterBinding.ensureInitialized();
  12. bool isLogin = await SpUtil.get("isLogin", false);
  13. runApp(MyApp(
  14. isLogin: isLogin,
  15. ));
  16. }
  17. class MyApp extends StatelessWidget {
  18. bool isLogin = false;
  19. MyApp({Key? key, required this.isLogin}) : super(key: key);
  20. // This widget is the root of your application.
  21. @override
  22. Widget build(BuildContext context) {
  23. return ScreenUtilInit(
  24. designSize: const Size(750, 1344),
  25. builder: (BuildContext context, Widget? child) {
  26. return MaterialApp(
  27. title: '追踪者',
  28. theme: ThemeData(
  29. primarySwatch: Colors.blue,
  30. ),
  31. debugShowCheckedModeBanner: false,
  32. home: isLogin ? const IndexPage() : const WelComePage(),
  33. onGenerateRoute: Routes.generateRoute,
  34. );
  35. },
  36. );
  37. }
  38. }