Skip to content

Commit bc304c3

Browse files
committed
2 parents 86c1091 + 4bf3457 commit bc304c3

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

lib/tools/net_config.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ class NetConfig{
139139
}
140140
} on TimeoutException{
141141
print('TimeoutException');
142-
return 504;
142+
return 408;
143+
} on Exception {
144+
Tools.showToast('check your network');
145+
if(errorCallback!=null){
146+
errorCallback();
147+
}
148+
return 600;
143149
}
144150

145151
// Fluttertoast.cancel();

lib/view/main_view/splash.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ class _SplashState extends State<Splash> {
9999
_checkVersion() async {
100100

101101
// Invoke api.
102-
var data = await NetConfig.get(context,NetConfig.getNewestVersion,timeOut: 5);
102+
var data = await NetConfig.get(context,NetConfig.getNewestVersion,timeOut: 5,);
103103

104-
if(data!=null&&data==504){
104+
if(data!=null&&(data==408||data==600)){
105105
refreshOpacity = 1;
106106
setState(() {});
107107
return;
@@ -238,8 +238,19 @@ class _SplashState extends State<Splash> {
238238

239239
//
240240
void _getUserInfo(SharedPreferences share) {
241-
242-
Future data = NetConfig.get(context,NetConfig.getUserInfo);
241+
Future data = NetConfig.get(
242+
context, NetConfig.getUserInfo,
243+
errorCallback: () {
244+
share.clear();
245+
GlobalInfo.clear();
246+
print('==> user is not exist');
247+
// show welcome page
248+
Navigator.of(context).pushAndRemoveUntil(
249+
MaterialPageRoute(builder: (context) => WelcomePageOne()),
250+
(route) => route == null,
251+
);
252+
}
253+
);
243254
// Tools.loadingAnimation(context);
244255
data.then((data) {
245256
if (data != null) {

0 commit comments

Comments
 (0)