From f5ae339b494529cd8ba13ec0e8a2eac41c9fa8eb Mon Sep 17 00:00:00 2001 From: datang Date: Tue, 23 Aug 2022 23:33:38 +0800 Subject: [PATCH] =?UTF-8?q?app=E5=90=8E=E5=8F=B0=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=8A=B6=E6=80=81=E4=BF=9D=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 2 -- lib/main.dart | 4 ---- lib/ui/loading.dart | 28 ++++++++++++++++++++++++++-- lib/ui/tab_navigator.dart | 5 +++-- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index f652ce3..d89382c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -20,13 +20,11 @@ def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } - def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } - apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" diff --git a/lib/main.dart b/lib/main.dart index f48df6c..6115b5d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -72,11 +72,7 @@ class _MyAppState extends State { void initState() { super.initState(); // final service = FlutterBackgroundService(); - // Future.delayed(const Duration(milliseconds: 0), () async { - // //Hive.initFlutter; - // }); _Getpermission(); - HiveStore.init(); registerWxApi( appId: "wxd930ea5d5a228f5f",universalLink:"https://your.univerallink.com/link/ " ); diff --git a/lib/ui/loading.dart b/lib/ui/loading.dart index aa06b38..71bac28 100644 --- a/lib/ui/loading.dart +++ b/lib/ui/loading.dart @@ -1,7 +1,15 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:project_telephony/ui/tab_navigator.dart'; import 'dart:async'; import 'package:project_telephony/utils/headers.dart'; +import 'package:provider/provider.dart'; + +import '../constants/environment/environment.dart'; +import '../providers/user_provider.dart'; +import '../utils/hive_store.dart'; +import 'login/login_page.dart'; class Loading extends StatefulWidget { Loading({Key? key}) : super(key: key); @@ -12,11 +20,27 @@ class Loading extends StatefulWidget { class _LoadingState extends State { + Future initialAll() async { + await HiveStore.init(); + } + @override void initState() { - // TODO: implement initState super.initState(); - + final userProvider = Provider.of(context, listen: false); + var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); + if (kDebugMode) { + print('env :$env'); + } + DevEV.instance.setEnvironment( context, environment: env == 'dev',); + Future.delayed(const Duration(milliseconds: 1000), () async { + await initialAll(); + if (!await userProvider.init()) { + await Get.offAll(() => const LoginPage()); + } else { + await Get.offAll(() => const TabNavigator()); + } + }); Future.delayed(const Duration(seconds: 3),(){ //3秒后跳转到其他路由 Navigator.of(context).pushReplacementNamed("/TabNavigator"); diff --git a/lib/ui/tab_navigator.dart b/lib/ui/tab_navigator.dart index 91aab9e..0bcf46b 100644 --- a/lib/ui/tab_navigator.dart +++ b/lib/ui/tab_navigator.dart @@ -5,6 +5,7 @@ import 'package:project_telephony/ui/user/user_page.dart'; import 'package:project_telephony/utils/headers.dart'; +import '../utils/hive_store.dart'; import 'home/home_page.dart'; class TabNavigator extends StatefulWidget { @@ -29,8 +30,8 @@ class _TabNavigatorState extends State super.initState(); //页面加载调用 Future.delayed(const Duration(milliseconds: 0), () async { - // Hive.initFLutter; - // await HiveStore.init() + //Hive.initFlutter; + await HiveStore.init(); }); _pages = [const HomePage(), const UserPage()]; _tabController = TabController(