基础组件库
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

147 linhas
4.9 KiB

  1. import 'dart:convert';
  2. import 'dart:io';
  3. import 'package:flutter/foundation.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_alibc/flutter_alibc.dart';
  6. import 'package:flutter_localizations/flutter_localizations.dart';
  7. import 'package:provider/provider.dart';
  8. import 'package:pull_to_refresh/pull_to_refresh.dart';
  9. import 'package:zhiying_base_widget/pages/home_page/home_page.dart';
  10. import 'package:zhiying_base_widget/pages/launch_page/launch_page.dart';
  11. import 'package:zhiying_base_widget/register.dart';
  12. import 'package:zhiying_comm/util/update/app_update_util.dart';
  13. import 'package:zhiying_comm/zhiying_comm.dart';
  14. import 'util/localizations_delegate.dart';
  15. import 'package:zhiying_base_widget/utils/mob_push_util.dart';
  16. import 'package:zhiying_business_college/register.dart';
  17. import 'package:zhiying_new_user_free/register.dart';
  18. import 'package:zhiying_wechat_teacher/register.dart';
  19. import 'package:zhiying_moments/register.dart';
  20. import 'package:zhiying_member_upgrade/register.dart';
  21. import 'package:zhiying_equity_card/zhiying_equity_card.dart';
  22. import 'package:zhiying_official/register.dart';
  23. import 'package:zhiying_base_widget/zhiying_base_widget.dart';
  24. import 'package:zhiying_acquisition/register.dart';
  25. import 'package:zhiying_credit_card/register.dart';
  26. void main() {
  27. FlutterError.onError = (FlutterErrorDetails details) {
  28. FlutterError.dumpErrorToConsole(details);
  29. print(details.exceptionAsString());
  30. // if (kReleaseMode) exit(1);
  31. };
  32. runApp(MyApp());
  33. }
  34. class MyApp extends StatefulWidget {
  35. @override
  36. _MyAppState createState() => _MyAppState();
  37. }
  38. class _MyAppState extends State<MyApp> {
  39. Widget getErrorWidget(BuildContext context, FlutterErrorDetails error) {
  40. var erroStr = '';
  41. const bool inProduction = const bool.fromEnvironment("dart.vm.product");
  42. if (!inProduction) {
  43. erroStr = error.exceptionAsString();
  44. }
  45. return Center(
  46. child: Text(
  47. "" + erroStr,
  48. style: Theme.of(context).textTheme.title.copyWith(color: Colors.grey[200]),
  49. ),
  50. );
  51. }
  52. @override
  53. void initState() {
  54. super.initState();
  55. print('初始化~~~~');
  56. BaseWidgetRegister.init();
  57. BusinessCollageRegister.init();
  58. NewUserFreeRegister.init();
  59. WeChatTeachRegister.init();
  60. FriendCircleRegister.init();
  61. MemberUpgradeRegister.init();
  62. EquityCardRegister.init();
  63. OfficialRegister.init();
  64. AcquisitionRegister.init();
  65. CreditCardRegister.init();
  66. print('初始化百川');
  67. FlutterAlibc.initAlibc(version: "", appName: "").then((result) {
  68. print("白川" + '${result.errorCode} ${result.errorMessage}');
  69. });
  70. MobPushUtil.setCanPush();
  71. EventUtil.instance.on().listen((event) {});
  72. const bool inProduction = const bool.fromEnvironment("dart.vm.product");
  73. if (!inProduction) {
  74. //debug app不更新 app更新插件
  75. AppUpdateUtil.initXUpdate();
  76. }
  77. }
  78. @override
  79. Widget build(BuildContext context) {
  80. ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
  81. return getErrorWidget(context, errorDetails);
  82. };
  83. return MultiProvider(
  84. providers: [
  85. ChangeNotifierProvider.value(value: UserInfoNotifier()),
  86. ],
  87. child: GestureDetector(
  88. onTap: () {
  89. FocusScopeNode currentFocus = FocusScope.of(context);
  90. if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
  91. FocusManager.instance.primaryFocus.unfocus();
  92. }
  93. },
  94. child: MaterialApp(
  95. builder: (context, child) {
  96. return MediaQuery(
  97. //设置文字大小不随系统设置改变
  98. data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
  99. child: child,
  100. );
  101. },
  102. navigatorObservers: [lifeObserver],
  103. theme: ThemeData(
  104. fontFamily: 'PingFang',
  105. primaryColor: HexColor.fromHex('#FF4242'),
  106. accentColor: HexColor.fromHex('#FF4242'),
  107. ),
  108. routes: <String, WidgetBuilder>{
  109. '/homePage': (BuildContext context) => HomeCenterPage(),
  110. },
  111. navigatorKey: navigatorKey,
  112. localizationsDelegates: [
  113. RefreshLocalizations.delegate,
  114. GlobalMaterialLocalizations.delegate,
  115. GlobalWidgetsLocalizations.delegate,
  116. CommonLocalizationsDelegate(),
  117. ],
  118. supportedLocales: [
  119. const Locale('en'),
  120. const Locale('zh'),
  121. ],
  122. localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales) {
  123. print("change language ${locale.toString()}");
  124. return locale;
  125. },
  126. home: LaunchPage(
  127. // builder: (context) => HomePage(),
  128. ),
  129. ),
  130. ),
  131. );
  132. }
  133. }
  134. // FocusScopeNode currentFocus = FocusScope.of(context);
  135. // if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
  136. // FocusManager.instance.primaryFocus.unfocus();
  137. // }