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

110 lines
3.3 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. MobPushUtil.setCanPush();
  51. // app更新插件
  52. AppUpdateUtil.initXUpdate();
  53. }
  54. @override
  55. Widget build(BuildContext context) {
  56. ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
  57. return getErrorWidget(context, errorDetails);
  58. };
  59. return MultiProvider(
  60. providers: [
  61. ChangeNotifierProvider.value(value: UserInfoNotifier()),
  62. ],
  63. child: MaterialApp(
  64. theme: ThemeData(
  65. primaryColor: HexColor.fromHex('#FF4242'),
  66. accentColor: HexColor.fromHex('#FF4242'),
  67. ),
  68. routes: <String, WidgetBuilder>{
  69. '/homePage': (BuildContext context) => HomePage(),
  70. },
  71. navigatorKey: navigatorKey,
  72. localizationsDelegates: [
  73. RefreshLocalizations.delegate,
  74. GlobalMaterialLocalizations.delegate,
  75. GlobalWidgetsLocalizations.delegate,
  76. CommonLocalizationsDelegate(),
  77. ],
  78. supportedLocales: [
  79. const Locale('en'),
  80. const Locale('zh'),
  81. ],
  82. localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales) {
  83. print("change language ${locale.toString()}");
  84. return locale;
  85. },
  86. home: GestureDetector(
  87. onTap: () {
  88. FocusScopeNode currentFocus = FocusScope.of(context);
  89. if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
  90. FocusManager.instance.primaryFocus.unfocus();
  91. }
  92. },
  93. child: LaunchPage(
  94. // builder: (context) => HomePage(),
  95. ),
  96. ),
  97. ),
  98. );
  99. }
  100. }