基础组件库
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

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