main.dart 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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:shared_preferences/shared_preferences.dart';
  6. import 'index_page.dart';
  7. import 'model/config.dart';
  8. /// Description:
  9. /// Time : 2021年12月03日 Friday
  10. /// Author : liuyuqi.gov@msncn
  11. void main() async {
  12. WidgetsFlutterBinding.ensureInitialized();
  13. Config.initConfig();
  14. SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
  15. bool isLogin = sharedPreferences.getBool("isLogin");
  16. isLogin ??= false;
  17. runApp(MyApp(
  18. isLogin: isLogin,
  19. ));
  20. }
  21. class MyApp extends StatelessWidget {
  22. bool isLogin = false;
  23. MyApp({Key key, this.isLogin}) : super(key: key);
  24. // This widget is the root of your application.
  25. @override
  26. Widget build(BuildContext context) {
  27. return ScreenUtilInit(
  28. designSize: const Size(750, 1344),
  29. builder: () => MaterialApp(
  30. title: '追踪者',
  31. theme: ThemeData(
  32. primarySwatch: Colors.blue,
  33. ),
  34. debugShowCheckedModeBanner: false,
  35. home: isLogin ? IndexPage() : WelComePage(),
  36. onGenerateRoute: Routes.generateRoute,
  37. ),
  38. );
  39. }
  40. }