基础组件库
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.
 
 
 
 
 

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