main.dart 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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: () => MaterialApp(
  26. title: '追踪者',
  27. theme: ThemeData(
  28. primarySwatch: Colors.blue,
  29. ),
  30. debugShowCheckedModeBanner: false,
  31. home: isLogin ? IndexPage() : WelComePage(),
  32. onGenerateRoute: Routes.generateRoute,
  33. ),
  34. );
  35. }
  36. }