基础组件库
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

4 年前
4 年前
4 年前
4 年前
4 年前
4 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import 'dart:convert';
  2. import 'dart:io';
  3. import 'package:flutter/foundation.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_alibc/flutter_alibc.dart';
  6. import 'package:flutter_localizations/flutter_localizations.dart';
  7. import 'package:provider/provider.dart';
  8. import 'package:pull_to_refresh/pull_to_refresh.dart';
  9. import 'package:zhiying_base_widget/pages/home_page/home_page.dart';
  10. import 'package:zhiying_base_widget/pages/launch_page/launch_page.dart';
  11. import 'package:zhiying_base_widget/register.dart';
  12. import 'package:zhiying_comm/util/update/app_update_util.dart';
  13. import 'package:zhiying_comm/zhiying_comm.dart';
  14. import 'util/localizations_delegate.dart';
  15. import 'package:zhiying_base_widget/utils/mob_push_util.dart';
  16. import 'package:zhiying_business_college/register.dart';
  17. import 'package:zhiying_new_user_free/register.dart';
  18. import 'package:zhiying_wechat_teacher/register.dart';
  19. import 'package:zhiying_moments/register.dart';
  20. import 'package:zhiying_member_upgrade/register.dart';
  21. import 'package:zhiying_equity_card/zhiying_equity_card.dart';
  22. import 'package:zhiying_official/register.dart';
  23. import 'package:zhiying_base_widget/zhiying_base_widget.dart';
  24. import 'package:zhiying_acquisition/register.dart';
  25. void main() {
  26. FlutterError.onError = (FlutterErrorDetails details) {
  27. FlutterError.dumpErrorToConsole(details);
  28. print(details.exceptionAsString());
  29. // if (kReleaseMode) exit(1);
  30. };
  31. runApp(MyApp());
  32. }
  33. class MyApp extends StatefulWidget {
  34. @override
  35. _MyAppState createState() => _MyAppState();
  36. }
  37. class _MyAppState extends State<MyApp> {
  38. Widget getErrorWidget(BuildContext context, FlutterErrorDetails error) {
  39. var erroStr = '';
  40. const bool inProduction = const bool.fromEnvironment("dart.vm.product");
  41. if (!inProduction) {
  42. erroStr = error.exceptionAsString();
  43. }
  44. return Center(
  45. child: Text(
  46. "" + erroStr,
  47. style: Theme.of(context).textTheme.title.copyWith(color: Colors.grey[200]),
  48. ),
  49. );
  50. }
  51. @override
  52. void initState() {
  53. super.initState();
  54. print('初始化~~~~');
  55. BaseWidgetRegister.init();
  56. BusinessCollageRegister.init();
  57. NewUserFreeRegister.init();
  58. WeChatTeachRegister.init();
  59. FriendCircleRegister.init();
  60. MemberUpgradeRegister.init();
  61. EquityCardRegister.init();
  62. OfficialRegister.init();
  63. AcquisitionRegister.init();
  64. print('初始化百川');
  65. FlutterAlibc.initAlibc(version: "", appName: "").then((result) {
  66. print("白川" + '${result.errorCode} ${result.errorMessage}');
  67. });
  68. MobPushUtil.setCanPush();
  69. EventUtil.instance.on().listen((event) {});
  70. const bool inProduction = const bool.fromEnvironment("dart.vm.product");
  71. if (!inProduction) {
  72. //debug app不更新 app更新插件
  73. AppUpdateUtil.initXUpdate();
  74. }
  75. }
  76. @override
  77. Widget build(BuildContext context) {
  78. ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
  79. return getErrorWidget(context, errorDetails);
  80. };
  81. return MultiProvider(
  82. providers: [
  83. ChangeNotifierProvider.value(value: UserInfoNotifier()),
  84. ],
  85. child: GestureDetector(
  86. onTap: () {
  87. FocusScopeNode currentFocus = FocusScope.of(context);
  88. if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
  89. FocusManager.instance.primaryFocus.unfocus();
  90. }
  91. },
  92. child: MaterialApp(
  93. builder: (context, child) {
  94. return MediaQuery(
  95. //设置文字大小不随系统设置改变
  96. data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
  97. child: child,
  98. );
  99. },
  100. theme: ThemeData(
  101. fontFamily: 'PingFang',
  102. primaryColor: HexColor.fromHex('#FF4242'),
  103. accentColor: HexColor.fromHex('#FF4242'),
  104. ),
  105. routes: <String, WidgetBuilder>{
  106. '/homePage': (BuildContext context) => HomeCenterPage(),
  107. },
  108. navigatorKey: navigatorKey,
  109. localizationsDelegates: [
  110. RefreshLocalizations.delegate,
  111. GlobalMaterialLocalizations.delegate,
  112. GlobalWidgetsLocalizations.delegate,
  113. CommonLocalizationsDelegate(),
  114. ],
  115. supportedLocales: [
  116. const Locale('en'),
  117. const Locale('zh'),
  118. ],
  119. localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales) {
  120. print("change language ${locale.toString()}");
  121. return locale;
  122. },
  123. home: LaunchPage(
  124. // builder: (context) => HomePage(),
  125. ),
  126. ),
  127. ),
  128. );
  129. }
  130. }
  131. // FocusScopeNode currentFocus = FocusScope.of(context);
  132. // if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
  133. // FocusManager.instance.primaryFocus.unfocus();
  134. // }