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

main.dart 5.9 KiB

3 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
4 jaren geleden
3 jaren geleden
3 jaren geleden
4 jaren geleden
4 jaren geleden
3 jaren geleden
3 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. import 'package:zhiying_shopping_mall/zhiying_shopping_mall.dart';
  26. import 'package:zhiying_credit_card/register.dart';
  27. import 'package:zhiying_base_widget/zhiying_base_widget.dart';
  28. void main() {
  29. FlutterError.onError = (FlutterErrorDetails details) {
  30. FlutterError.dumpErrorToConsole(details);
  31. print(details.exceptionAsString());
  32. // if (kReleaseMode) exit(1);
  33. };
  34. runApp(MyApp());
  35. }
  36. class MyApp extends StatefulWidget {
  37. @override
  38. _MyAppState createState() => _MyAppState();
  39. }
  40. class _MyAppState extends State<MyApp> {
  41. Widget getErrorWidget(BuildContext context, FlutterErrorDetails error) {
  42. var erroStr = '';
  43. const bool inProduction = const bool.fromEnvironment("dart.vm.product");
  44. if (!inProduction) {
  45. erroStr = error.exceptionAsString();
  46. }
  47. return Center(
  48. child: Text(
  49. "" + erroStr,
  50. style: Theme.of(context).textTheme.title.copyWith(color: Colors.grey[200]),
  51. ),
  52. );
  53. }
  54. @override
  55. void initState() {
  56. super.initState();
  57. print('初始化~~~~');
  58. BaseWidgetRegister.init();
  59. BusinessCollageRegister.init();
  60. NewUserFreeRegister.init();
  61. WeChatTeachRegister.init();
  62. FriendCircleRegister.init();
  63. MemberUpgradeRegister.init();
  64. EquityCardRegister.init();
  65. OfficialRegister.init();
  66. AcquisitionRegister.init();
  67. ShoppingMallRegister.init();
  68. CreditCardRegister.init();
  69. // print('初始化百川');
  70. FlutterAlibc.initAlibc(version: "", appName: "").then((result) {
  71. print("百川" + '${result.errorCode} ${result.errorMessage}');
  72. });
  73. // MobPushUtil.setCanPush();
  74. //
  75. // EventUtil.instance.on().listen((event) {});
  76. //
  77. // initUpdate();
  78. }
  79. initUpdate() async {
  80. // const bool inProduction = const bool.fromEnvironment("dart.vm.product");
  81. // if (!inProduction) {
  82. // //debug app不更新 app更新插件
  83. // AppUpdateUtil.initXUpdate();
  84. // }
  85. }
  86. @override
  87. Widget build(BuildContext context) {
  88. ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
  89. return getErrorWidget(context, errorDetails);
  90. };
  91. return MultiProvider(
  92. providers: [
  93. ChangeNotifierProvider.value(value: UserInfoNotifier()),
  94. ],
  95. child: GestureDetector(
  96. onTap: () {
  97. FocusScopeNode currentFocus = FocusScope.of(context);
  98. if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
  99. FocusManager.instance.primaryFocus.unfocus();
  100. }
  101. },
  102. child: MaterialApp(
  103. builder: (context, child) {
  104. return MediaQuery(
  105. //设置文字大小不随系统设置改变
  106. data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
  107. child: child,
  108. );
  109. },
  110. // navigatorObservers: [lifeObserver],
  111. theme: ThemeData(
  112. fontFamily: 'PingFang',
  113. primaryColor: HexColor.fromHex('#FF4242'),
  114. accentColor: HexColor.fromHex('#FF4242'),
  115. ),
  116. routes: <String, WidgetBuilder>{
  117. '/homePage': (BuildContext context) => HomeCenterPage(),
  118. },
  119. navigatorKey: navigatorKey,
  120. localizationsDelegates: [
  121. RefreshLocalizations.delegate,
  122. GlobalMaterialLocalizations.delegate,
  123. GlobalWidgetsLocalizations.delegate,
  124. CommonLocalizationsDelegate(),
  125. ],
  126. supportedLocales: [
  127. const Locale('en'),
  128. const Locale('zh'),
  129. ],
  130. localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales) {
  131. print("change language ${locale.toString()}");
  132. return locale;
  133. },
  134. home: LaunchPage(
  135. // builder: (context) => HomePage(),
  136. ),
  137. ),
  138. ),
  139. );
  140. }
  141. }
  142. // FocusScopeNode currentFocus = FocusScope.of(context);
  143. // if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
  144. // FocusManager.instance.primaryFocus.unfocus();
  145. // }
  146. class TestPage extends StatefulWidget {
  147. @override
  148. _TestPageState createState() => _TestPageState();
  149. }
  150. class _TestPageState extends State<TestPage> {
  151. @override
  152. void initState() {
  153. NativeUtil.notifyInitSuccess();
  154. super.initState();
  155. }
  156. @override
  157. Widget build(BuildContext context) {
  158. return Scaffold(
  159. appBar: AppBar(
  160. title: Text("临时测试页"),
  161. ),
  162. body: Container(
  163. child: ListView(
  164. children: [
  165. ListTile(
  166. title: Text("查询页"),
  167. onTap: () {
  168. Navigator.push(context, MaterialPageRoute(builder: (context) => OrderFoundSearchPage()));
  169. },
  170. )
  171. ],
  172. ),
  173. ),
  174. );
  175. }
  176. }