基础组件库
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 

99 рядки
3.0 KiB

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