基础组件库
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

152 строки
5.0 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. //
  72. // EventUtil.instance.on().listen((event) {});
  73. //
  74. // initUpdate();
  75. }
  76. initUpdate() async {
  77. // const bool inProduction = const bool.fromEnvironment("dart.vm.product");
  78. // if (!inProduction) {
  79. // //debug app不更新 app更新插件
  80. // AppUpdateUtil.initXUpdate();
  81. // }
  82. }
  83. @override
  84. Widget build(BuildContext context) {
  85. ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
  86. return getErrorWidget(context, errorDetails);
  87. };
  88. return MultiProvider(
  89. providers: [
  90. ChangeNotifierProvider.value(value: UserInfoNotifier()),
  91. ],
  92. child: GestureDetector(
  93. onTap: () {
  94. FocusScopeNode currentFocus = FocusScope.of(context);
  95. if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
  96. FocusManager.instance.primaryFocus.unfocus();
  97. }
  98. },
  99. child: MaterialApp(
  100. builder: (context, child) {
  101. return MediaQuery(
  102. //设置文字大小不随系统设置改变
  103. data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
  104. child: child,
  105. );
  106. },
  107. navigatorObservers: [lifeObserver],
  108. theme: ThemeData(
  109. fontFamily: 'PingFang',
  110. primaryColor: HexColor.fromHex('#FF4242'),
  111. accentColor: HexColor.fromHex('#FF4242'),
  112. ),
  113. routes: <String, WidgetBuilder>{
  114. '/homePage': (BuildContext context) => HomeCenterPage(),
  115. },
  116. navigatorKey: navigatorKey,
  117. localizationsDelegates: [
  118. RefreshLocalizations.delegate,
  119. GlobalMaterialLocalizations.delegate,
  120. GlobalWidgetsLocalizations.delegate,
  121. CommonLocalizationsDelegate(),
  122. ],
  123. supportedLocales: [
  124. const Locale('en'),
  125. const Locale('zh'),
  126. ],
  127. localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales) {
  128. print("change language ${locale.toString()}");
  129. return locale;
  130. },
  131. home: LaunchPage(
  132. // builder: (context) => HomePage(),
  133. ),
  134. ),
  135. ),
  136. );
  137. }
  138. }
  139. // FocusScopeNode currentFocus = FocusScope.of(context);
  140. // if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
  141. // FocusManager.instance.primaryFocus.unfocus();
  142. // }