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

94 linhas
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: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 'package:jdsdk/jdsdk.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: 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. print('初始化京东~');
  45. Jdsdk.init(appKey: 'c0abbe1f201464ee139d613591a1be02', appSecret: 'a0eeac7105bf4c7cb573972aa03ed95c');
  46. // app更新插件
  47. AppUpdateUtil.initXUpdate();
  48. }
  49. @override
  50. Widget build(BuildContext context) {
  51. ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
  52. return getErrorWidget(context, errorDetails);
  53. };
  54. return MultiProvider(
  55. providers: [
  56. ChangeNotifierProvider.value(value: UserInfoNotifier()),
  57. ],
  58. child: MaterialApp(
  59. localizationsDelegates: [
  60. RefreshLocalizations.delegate,
  61. GlobalMaterialLocalizations.delegate,
  62. GlobalWidgetsLocalizations.delegate,
  63. CommonLocalizationsDelegate(),
  64. ],
  65. supportedLocales: [
  66. const Locale('en'),
  67. const Locale('zh'),
  68. ],
  69. localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales) {
  70. print("change language ${locale.toString()}");
  71. return locale;
  72. },
  73. home: GestureDetector(
  74. onTap: () {
  75. FocusScopeNode currentFocus = FocusScope.of(context);
  76. if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
  77. FocusManager.instance.primaryFocus.unfocus();
  78. }
  79. },
  80. child: LaunchPage(
  81. builder: (context) => HomePage(),
  82. ),
  83. ),
  84. ),
  85. );
  86. }
  87. }