main.dart 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import 'package:fast/constants.dart';
  2. import 'package:fast/utils/api.dart';
  3. import 'package:fast/utils/global.dart';
  4. import 'package:fast/utils/http_utils.dart';
  5. import 'package:fast/utils/storage.dart';
  6. import 'package:fast/view/index.dart';
  7. import 'package:fast/view/invite_code.dart';
  8. import 'package:fast/view/phone_code.dart';
  9. import 'package:flutter/material.dart';
  10. import 'package:flutter/services.dart';
  11. import 'package:get/get.dart';
  12. Future<void> main() async {
  13. WidgetsFlutterBinding.ensureInitialized();
  14. await initStore();
  15. runApp(const MyApp());
  16. SystemUiOverlayStyle style = const SystemUiOverlayStyle(
  17. statusBarColor: Colors.transparent,
  18. statusBarIconBrightness: Brightness.light);
  19. SystemChrome.setSystemUIOverlayStyle(style);
  20. }
  21. Future<void> initStore() async {
  22. HttpUtils.init(baseUrl: Api.baseUrl);
  23. await StorageUtil().init();
  24. if (StorageUtil().prefs!.getString("token") != null){
  25. Global().token = StorageUtil().prefs!.getString("token")!;
  26. }
  27. }
  28. class MyApp extends StatelessWidget {
  29. const MyApp({Key? key}) : super(key: key);
  30. // This widget is the root of your application.
  31. @override
  32. Widget build(BuildContext context) {
  33. RouteObserver<ModalRoute> routeObserver = RouteObserver<ModalRoute>();
  34. Global().routeObserver = routeObserver;
  35. return GetMaterialApp(
  36. title: 'Fast',
  37. debugShowCheckedModeBanner: false,
  38. theme: ThemeData(
  39. // fontFamily: "Exo2",
  40. scaffoldBackgroundColor: kBgColor,
  41. backgroundColor: Colors.white,
  42. // This is the theme of your application.
  43. //
  44. // Try running your application with "flutter run". You'll see the
  45. // application has a blue toolbar. Then, without quitting the app, try
  46. // changing the primarySwatch below to Colors.green and then invoke
  47. // "hot reload" (press "r" in the console where you ran "flutter run",
  48. // or simply save your changes to "hot reload" in a Flutter IDE).
  49. // Notice that the counter didn't reset back to zero; the application
  50. // is not restarted.
  51. primarySwatch: Colors.blue,
  52. ),
  53. home: const IndexScreen(), //const InviteCode(),//const Calendar()//
  54. // home: const HomeScreen(),
  55. navigatorObservers: [routeObserver],
  56. );
  57. }
  58. }