基础组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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