import 'dart:convert'; import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_alibc/flutter_alibc.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:zhiying_base_widget/pages/home_page/home_page.dart'; import 'package:zhiying_base_widget/pages/launch_page/launch_page.dart'; import 'package:zhiying_base_widget/register.dart'; import 'package:zhiying_comm/util/update/app_update_util.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; import 'util/localizations_delegate.dart'; import 'package:zhiying_base_widget/utils/mob_push_util.dart'; import 'package:zhiying_business_college/register.dart'; import 'package:zhiying_new_user_free/register.dart'; import 'package:zhiying_wechat_teacher/register.dart'; void main() { FlutterError.onError = (FlutterErrorDetails details) { FlutterError.dumpErrorToConsole(details); print(details.exceptionAsString()); // if (kReleaseMode) exit(1); }; runApp(MyApp()); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { Widget getErrorWidget(BuildContext context, FlutterErrorDetails error) { return Center( child: Text( "走神了~\n${error.exceptionAsString()}", style: Theme .of(context) .textTheme .title .copyWith(color: Colors.redAccent), ), ); } @override void initState() { super.initState(); print('初始化~~~~'); BaseWidgetRegister.init(); BusinessCollageRegister.init(); NewUserFreeRegister.init(); WeChatTeachRegister.init(); print('初始化百川'); FlutterAlibc.initAlibc(version: "", appName: "").then((result) { print("白川" + '${result.errorCode} ${result.errorMessage}'); }); MobPushUtil.setCanPush(); // app更新插件 AppUpdateUtil.initXUpdate(); } @override Widget build(BuildContext context) { ErrorWidget.builder = (FlutterErrorDetails errorDetails) { return getErrorWidget(context, errorDetails); }; return MultiProvider( providers: [ ChangeNotifierProvider.value(value: UserInfoNotifier()), ], child: MaterialApp( builder: (context,child){ return MediaQuery( //设置文字大小不随系统设置改变 data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), child: child, ); }, theme: ThemeData( fontFamily: 'PingFang', primaryColor: HexColor.fromHex('#FF4242'), accentColor: HexColor.fromHex('#FF4242'), ), routes: { '/homePage': (BuildContext context) => HomePage(), }, navigatorKey: navigatorKey, localizationsDelegates: [ RefreshLocalizations.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, CommonLocalizationsDelegate(), ], supportedLocales: [ const Locale('en'), const Locale('zh'), ], localeResolutionCallback: (Locale locale, Iterable supportedLocales) { print("change language ${locale.toString()}"); return locale; }, home: GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) { FocusManager.instance.primaryFocus.unfocus(); } }, child: LaunchPage( // builder: (context) => HomePage(), ), ), ), ); } }