|
- import 'package:flutter/foundation.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_alibc/flutter_alibc.dart';
- import 'package:provider/provider.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/zhiying_comm.dart';
- import 'package:flutter_localizations/flutter_localizations.dart';
- import 'package:pull_to_refresh/pull_to_refresh.dart';
- import 'package:zhiying_comm/util/update/app_update_util.dart';
- import 'package:jdsdk/jdsdk.dart';
-
- import 'util/localizations_delegate.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}');
- });
- print('初始化京东~');
- Jdsdk.init(appKey: 'c0abbe1f201464ee139d613591a1be02', appSecret: 'a0eeac7105bf4c7cb573972aa03ed95c');
- // 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(
- 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(),
- ),
- ),
- ),
- );
- }
- }
|