main.dart 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import 'dart:async';
  2. import 'package:flutter_localizations/flutter_localizations.dart';
  3. import 'package:fis_i18n/i18n.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_easyloading/flutter_easyloading.dart';
  6. import 'package:flyinsonolite/consultation/records/views/applyconsultationpage.dart';
  7. import 'package:flyinsonolite/consultation/liveconsultation/views/liveconsultationpage.dart';
  8. import 'package:flyinsonolite/consultation/records/views/consultationlistpage.dart';
  9. import 'package:flyinsonolite/controls/prompt.dart';
  10. import 'package:flyinsonolite/jsonrpc/fisLib/services/index.dart';
  11. import 'package:flyinsonolite/infrastructure/global.dart';
  12. import 'package:flyinsonolite/home/views/homepage.dart';
  13. import 'package:flyinsonolite/infrastructure/logger.dart';
  14. import 'package:flyinsonolite/infrastructure/storage.dart';
  15. import 'package:flyinsonolite/helpers/parameterhelper.dart';
  16. import 'package:flyinsonolite/infrastructure/routeconstants.dart';
  17. import 'package:get/get.dart';
  18. import 'login/views/loginpage.dart';
  19. void main() async {
  20. runZonedGuarded(() async {
  21. var route = '/login/zh/purple';
  22. try {
  23. WidgetsFlutterBinding.ensureInitialized();
  24. await Global.initAsync();
  25. if (ParameterHelper.parameterMap.containsKey('page')) {
  26. var pageParameter = ParameterHelper.parameterMap['page'];
  27. if (pageParameter == 'liveconsultation') {
  28. route = RouteConstants.consultationRouteConstants.liveconsultation;
  29. }
  30. }
  31. } catch (e) {
  32. loggerAsyn(FISDeviceLogCategory.Error, 'Global init Error:{$e}');
  33. }
  34. runApp(GetMaterialApp(
  35. theme: Storage.currentTheme.themeData,
  36. locale: i18nBook.locale,
  37. supportedLocales: const [Locale("en", "US"), Locale("zh", "CN")],
  38. localizationsDelegates: const [
  39. GlobalMaterialLocalizations.delegate, // 指定本地化的字符串和一些其他的值
  40. GlobalCupertinoLocalizations.delegate, // 对应的Cupertino风格
  41. GlobalWidgetsLocalizations.delegate // 指定默认的文本排列方向, 由左到右或由右到左
  42. ],
  43. initialRoute: route,
  44. getPages: [
  45. GetPage(name: RouteConstants.login, page: () => LoginPage()),
  46. GetPage(name: RouteConstants.home, page: () => HomePage()),
  47. GetPage(
  48. name: RouteConstants.consultationRouteConstants.consultationList,
  49. page: () => ConsultationListPage()),
  50. GetPage(
  51. name: RouteConstants.consultationRouteConstants.applyconsultation,
  52. page: () => const ApplyConsultationPage()),
  53. GetPage(
  54. name: RouteConstants.consultationRouteConstants.liveconsultation,
  55. page: () => LiveConsultationPage())
  56. ],
  57. builder: EasyLoading.init(
  58. builder: (context, widget) {
  59. Storage.isPortraitMode.value = Get.width < Get.height;
  60. PromptBox.init();
  61. return DefaultAssetBundle(
  62. bundle: Global.assetBundle,
  63. child: MediaQuery(
  64. data: MediaQuery.of(context),
  65. child: widget ?? Container(),
  66. ),
  67. );
  68. },
  69. ),
  70. ));
  71. }, (error, stack) async {
  72. await loggerAsyn(FISDeviceLogCategory.Error,
  73. 'FlyinsonoLite An unexpected exception occurs{$error}');
  74. });
  75. }