基础组件库
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

main.dart 2.8 KiB

4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. }