From 318359db05e3287e548e4e96d159bce7740afd67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Wed, 26 May 2021 19:51:08 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=BC=80=E5=B1=8F=E5=B9=BF=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/home_page/home_page.dart | 6 ++++++ lib/pages/launch_page/launch_page.dart | 23 ++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/pages/home_page/home_page.dart b/lib/pages/home_page/home_page.dart index e9072f9..f0d1a81 100644 --- a/lib/pages/home_page/home_page.dart +++ b/lib/pages/home_page/home_page.dart @@ -70,6 +70,7 @@ class _HomePageState extends State with WidgetsBindingObserver, Ticker @override void initState() { ///初始化一些数据 + initAsync(); //如果登出则重新打开首页 @@ -93,6 +94,11 @@ class _HomePageState extends State with WidgetsBindingObserver, Ticker ///初始化各种监听 initAsync() async { try { + Future.delayed(Duration(milliseconds: 10), () async { + GlobalConfig.context = context; + await AdvertisingUtils.openSplashAd(); + }); + WidgetsBinding.instance.addObserver(this); // mob锁粉隐私协议提交 diff --git a/lib/pages/launch_page/launch_page.dart b/lib/pages/launch_page/launch_page.dart index 5ef9df2..6b4c83d 100644 --- a/lib/pages/launch_page/launch_page.dart +++ b/lib/pages/launch_page/launch_page.dart @@ -26,6 +26,7 @@ import 'package:zhiying_comm/util/shared_prefe_util.dart'; import 'package:package_info/package_info.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:zhiying_comm/util/update/app_update_util.dart'; + // 启动页,页面初始化等操作~跟原生启动页保持一致,防止白屏问题 class LaunchPage extends StatefulWidget { final WidgetBuilder builder; @@ -57,19 +58,20 @@ class _LaunchPageState extends State with TickerProviderStateMixin { ///检查是否覆盖安装 //取masterId - String lasterMasterId = await SharedPreferencesUtil.getStringValue(Constants.masterId, defaultVal: "1"); - Map setting = await NativeUtil.getSetting(); - String masterId = setting['master_id']; - if (lasterMasterId != "1") { - if (masterId != lasterMasterId) { - await SharedPreferencesUtil.clean(); - } + String lasterMasterId = await SharedPreferencesUtil.getStringValue(Constants.masterId, defaultVal: "1"); + Map setting = await NativeUtil.getSetting(); + String masterId = setting['master_id']; + if (lasterMasterId != "1") { + if (masterId != lasterMasterId) { + await SharedPreferencesUtil.clean(); } - SharedPreferencesUtil.setStringValue(Constants.masterId, masterId); - - + } + SharedPreferencesUtil.setStringValue(Constants.masterId, masterId); Application.init().then((_) async { + ///初始化广告SDK + await AdvertisingUtils.init(); + ///引导页 PackageInfo packageInfo = await PackageInfo.fromPlatform(); String versionNumber = await SharedPreferencesUtil.getStringValue(Constants.versionNumber); @@ -86,7 +88,6 @@ class _LaunchPageState extends State with TickerProviderStateMixin { // CupertinoPageRoute(builder: (context) => HomePage())); print("打开首页"); Navigator.of(context).pushReplacementNamed('/homePage'); - } }).catchError((err, s) async { print(s);