基础组件库
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

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