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

4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. theme: ThemeData(
  58. primaryColor: HexColor.fromHex('#FF4242'),
  59. accentColor: HexColor.fromHex('#FF4242'),
  60. ),
  61. routes: <String, WidgetBuilder>{
  62. '/homePage': (BuildContext context) => HomePage() ,
  63. },
  64. navigatorKey: navigatorKey,
  65. localizationsDelegates: [
  66. RefreshLocalizations.delegate,
  67. GlobalMaterialLocalizations.delegate,
  68. GlobalWidgetsLocalizations.delegate,
  69. CommonLocalizationsDelegate(),
  70. ],
  71. supportedLocales: [
  72. const Locale('en'),
  73. const Locale('zh'),
  74. ],
  75. localeResolutionCallback:
  76. (Locale locale, Iterable<Locale> supportedLocales) {
  77. print("change language ${locale.toString()}");
  78. return locale;
  79. },
  80. home: GestureDetector(
  81. onTap: () {
  82. FocusScopeNode currentFocus = FocusScope.of(context);
  83. if (!currentFocus.hasPrimaryFocus &&
  84. currentFocus.focusedChild != null) {
  85. FocusManager.instance.primaryFocus.unfocus();
  86. }
  87. },
  88. child: LaunchPage(
  89. // builder: (context) => HomePage(),
  90. ),
  91. ),
  92. ),
  93. );
  94. }
  95. }