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

91 line
2.8 KiB

  1. import 'package:flutter/foundation.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_alibc/flutter_alibc.dart';
  4. import 'package:provider/provider.dart';
  5. import 'package:zhiying_base_widget/pages/home_page/home_page.dart';
  6. import 'package:zhiying_base_widget/pages/launch_page/launch_page.dart';
  7. import 'package:zhiying_base_widget/register.dart';
  8. import 'package:zhiying_comm/zhiying_comm.dart';
  9. import 'package:flutter_localizations/flutter_localizations.dart';
  10. import 'package:pull_to_refresh/pull_to_refresh.dart';
  11. import 'package:zhiying_comm/util/update/app_update_util.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: Theme.of(context).textTheme.title.copyWith(color: Colors.redAccent),
  31. ),
  32. );
  33. }
  34. @override
  35. void initState() {
  36. super.initState();
  37. print('初始化~~~~');
  38. BaseWidgetRegister.init();
  39. print('初始化百川');
  40. FlutterAlibc.initAlibc(version: "", appName: "").then((result) {
  41. print("白川" + '${result.errorCode} ${result.errorMessage}');
  42. });
  43. // app更新插件
  44. AppUpdateUtil.initXUpdate();
  45. }
  46. @override
  47. Widget build(BuildContext context) {
  48. ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
  49. return getErrorWidget(context, errorDetails);
  50. };
  51. return MultiProvider(
  52. providers: [
  53. ChangeNotifierProvider.value(value: UserInfoNotifier()),
  54. ],
  55. child: MaterialApp(
  56. localizationsDelegates: [
  57. RefreshLocalizations.delegate,
  58. GlobalMaterialLocalizations.delegate,
  59. GlobalWidgetsLocalizations.delegate,
  60. CommonLocalizationsDelegate(),
  61. ],
  62. supportedLocales: [
  63. const Locale('en'),
  64. const Locale('zh'),
  65. ],
  66. localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales) {
  67. print("change language ${locale.toString()}");
  68. return locale;
  69. },
  70. home: GestureDetector(
  71. onTap: () {
  72. FocusScopeNode currentFocus = FocusScope.of(context);
  73. if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
  74. FocusManager.instance.primaryFocus.unfocus();
  75. }
  76. },
  77. child: LaunchPage(
  78. builder: (context) => HomePage(),
  79. ),
  80. ),
  81. ),
  82. );
  83. }
  84. }