解决 应用被后台杀掉 再次启动会卡在启动页的问题

hmxc
张萌 4 years ago
parent 32c8ca64ac
commit 5ede9cc5f7

@ -50,7 +50,7 @@ class _HomePageState extends State<HomePage>
List<dynamic>? data;
EasyRefreshController _refreshController = EasyRefreshController();
late EasyRefreshController _refreshController;
int page = 1;
@ -61,6 +61,14 @@ class _HomePageState extends State<HomePage>
void initState() {
super.initState();
_scrollController = ScrollController();
_refreshController = EasyRefreshController();
}
@override
void dispose() {
_refreshController.dispose();
_scrollController?.dispose();
super.dispose();
}
@override

@ -58,7 +58,11 @@ class _SplashPageState extends State<SplashPage> {
context,
debug: DeveloperUtil.dev,
);
_initOp().then((value) => Get.offAll(() => TabNavigator()));
Future.delayed(Duration(milliseconds: 1000), () async {
await _initOp();
Get.offAll(() => TabNavigator());
});
// _initOp().then((value) => Get.offAll(() => TabNavigator()));
}
@override

@ -1,14 +1,13 @@
import 'package:aku_community/base/base_style.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:aku_community/const/resource.dart';
import 'package:aku_community/ui/community/community_views/community_page.dart';
import 'package:aku_community/ui/market/market_page.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:get/get.dart';
import 'home/home_page.dart';
import 'personal/personal_page.dart';
import 'property/property_index.dart';
@ -99,59 +98,15 @@ class _TabNavigatorState extends State<TabNavigator>
return BeeScaffold(
body: WillPopScope(
onWillPop: () async {
// if (_lastPressed == null ||
// DateTime.now().difference(_lastPressed!) > Duration(seconds: 1)) {
// //1
// _lastPressed = DateTime.now();
// BotToast.showText(text: '再点击一次返回退出');
// return false;
// }
if (_lastPressed == null ||
DateTime.now().difference(_lastPressed!) > Duration(seconds: 1)) {
//1
_lastPressed = DateTime.now();
BotToast.showText(text: '再点击一次返回退出');
return false;
}
//app
bool _reslut = true;
showCupertinoDialog(
context: context,
builder: (context) {
return CupertinoAlertDialog(
title: Text(
'确认退出?',
style: TextStyle(
color: Colors.black,
fontSize: 40.sp,
fontWeight: FontWeight.bold,
),
),
actions: [
CupertinoActionSheetAction(
onPressed: () {
Get.back();
},
child: Text(
'确认',
style: TextStyle(
color: Colors.black,
fontSize: 32.sp,
fontWeight: FontWeight.bold,
),
),
),
CupertinoActionSheetAction(
onPressed: () {
Get.back();
_reslut = false;
},
child: Text(
'取消',
style: TextStyle(
color: kPrimaryColor,
fontSize: 32.sp,
fontWeight: FontWeight.bold,
),
),
)
],
);
});
return _reslut;
return true;
},
child: TabBarView(
children: _pages,

@ -22,7 +22,7 @@ class UserProvider extends ChangeNotifier {
bool _isLogin = false;
bool get isLogin => _isLogin;
bool get isNotLogin => !_isLogin;
Future setLogin(int? token) async {
Future setLogin(int token) async {
final appProvider = Provider.of<AppProvider>(Get.context!, listen: false);
_isLogin = true;
NetUtil().dio!.options.headers.putIfAbsent('App-Admin-Token', () => token);
@ -52,7 +52,7 @@ class UserProvider extends ChangeNotifier {
Future updateProfile() async {
_userInfoModel = await SignFunc.getUserInfo();
if (_userInfoModel != null && !kIsWeb && !Platform.isMacOS) {
await JPush().setAlias(_userInfoModel!.id.toString());
await JPush().setAlias(_userInfoModel?.id.toString()??'');
}
notifyListeners();
}

Loading…
Cancel
Save