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

102 rivejä
2.9 KiB

  1. import 'dart:io';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_alibc/flutter_alibc.dart';
  5. import 'package:flutter_localizations/flutter_localizations.dart';
  6. import 'package:provider/provider.dart';
  7. import 'package:pull_to_refresh/pull_to_refresh.dart';
  8. import 'package:zhiying_base_widget/pages/home_page/home_page.dart';
  9. import 'package:zhiying_base_widget/pages/launch_page/launch_page.dart';
  10. import 'package:zhiying_base_widget/register.dart';
  11. import 'package:zhiying_comm/util/update/app_update_util.dart';
  12. import 'package:zhiying_comm/zhiying_comm.dart';
  13. import 'util/localizations_delegate.dart';
  14. void main() {
  15. FlutterError.onError = (FlutterErrorDetails details) {
  16. FlutterError.dumpErrorToConsole(details);
  17. print(details.exceptionAsString());
  18. // if (kReleaseMode) exit(1);
  19. };
  20. runApp(MyApp());
  21. }
  22. class MyApp extends StatefulWidget {
  23. @override
  24. _MyAppState createState() => _MyAppState();
  25. }
  26. class _MyAppState extends State<MyApp> {
  27. Widget getErrorWidget(BuildContext context, FlutterErrorDetails error) {
  28. return Center(
  29. child: Text(
  30. "走神了~\n${error.exceptionAsString()}",
  31. style:
  32. Theme
  33. .of(context)
  34. .textTheme
  35. .title
  36. .copyWith(color: Colors.redAccent),
  37. ),
  38. );
  39. }
  40. @override
  41. void initState() {
  42. super.initState();
  43. print('初始化~~~~');
  44. BaseWidgetRegister.init();
  45. print('初始化百川');
  46. FlutterAlibc.initAlibc(version: "", appName: "").then((result) {
  47. print("白川" + '${result.errorCode} ${result.errorMessage}');
  48. });
  49. // app更新插件
  50. AppUpdateUtil.initXUpdate();
  51. }
  52. @override
  53. Widget build(BuildContext context) {
  54. ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
  55. return getErrorWidget(context, errorDetails);
  56. };
  57. return MultiProvider(
  58. providers: [
  59. ChangeNotifierProvider.value(value: UserInfoNotifier()),
  60. ],
  61. child: MaterialApp(
  62. navigatorKey: navigatorKey,
  63. localizationsDelegates: [
  64. RefreshLocalizations.delegate,
  65. GlobalMaterialLocalizations.delegate,
  66. GlobalWidgetsLocalizations.delegate,
  67. CommonLocalizationsDelegate(),
  68. ],
  69. supportedLocales: [
  70. const Locale('en'),
  71. const Locale('zh'),
  72. ],
  73. localeResolutionCallback:
  74. (Locale locale, Iterable<Locale> supportedLocales) {
  75. print("change language ${locale.toString()}");
  76. return locale;
  77. },
  78. home: GestureDetector(
  79. onTap: () {
  80. FocusScopeNode currentFocus = FocusScope.of(context);
  81. if (!currentFocus.hasPrimaryFocus &&
  82. currentFocus.focusedChild != null) {
  83. FocusManager.instance.primaryFocus.unfocus();
  84. }
  85. },
  86. child: LaunchPage(
  87. builder: (context) => HomePage(),
  88. ),
  89. ),
  90. ),
  91. );
  92. }
  93. }