基础组件库
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

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