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

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