|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- 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';
-
- 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<MyApp> {
- 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();
- 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: <String, WidgetBuilder>{
- '/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<Locale> 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(),
- ),
- ),
- ),
- );
- }
- }
|