diff --git a/lib/home/points_mall_page.dart b/lib/home/points_mall_page.dart index 1a609062..7514b407 100644 --- a/lib/home/points_mall_page.dart +++ b/lib/home/points_mall_page.dart @@ -72,15 +72,16 @@ class _PointsMallPage extends State } refreshUserInfo() { - SharedPreferences.getInstance().then((value) => { - client = ApiService(Dio(), - context: context, - token: value.getString('token'), - showLoading: false), - SmartDialog.showLoading(msg: S.current.zhengzaijiazai), - creditGoods(categoryId), - queryUser(), - }); + if(mounted) + SharedPreferences.getInstance().then((value) => { + client = ApiService(Dio(), + context: context, + token: value.getString('token'), + showLoading: false), + SmartDialog.showLoading(msg: S.current.zhengzaijiazai), + creditGoods(categoryId), + queryUser(), + }); } int pageNum = 1; diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index a6028723..4e565ac0 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -64,6 +64,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { super.initState(); refreshUserInfo(); eventBus.on().listen((event) { + print("EventType: Mine"); print("EventType: ${event.type}"); if (event.type < 3) { setState(() {}); @@ -72,23 +73,25 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { refreshUserInfo(); } }); + } refreshUserInfo() { - SharedPreferences.getInstance().then( - (value) => - { - apiService = ApiService(Dio(), - context: context, - token: value.getString('token'), - showLoading: false), - if (value.containsKey('user')) - { - userinfo = UserInfo.fromJson(jsonDecode(value.getString('user'))), - }, - queryUserInfo() - }, - ); + if(mounted) + SharedPreferences.getInstance().then( + (value) => + { + apiService = ApiService(Dio(), + context: context, + token: value.getString('token'), + showLoading: false), + if (value.containsKey('user') && value.getString('user') != null && value.getString('user') != "") + { + userinfo = UserInfo.fromJson(jsonDecode(value.getString('user'))), + }, + queryUserInfo() + }, + ); } UserInfo userinfo;