【发布时间】:2020-04-20 23:54:45
【问题描述】:
我正在尝试延迟导航到另一个屏幕,但延迟功能不起作用,控制台中也没有显示打印语句。最近我升级了flutter。不知道是不是这个原因。即使调试也无法正常工作。有时来回延迟会起作用。有时不会。
Padding(
padding: EdgeInsets.only(bottom: containerHeight * 0.08, top: 10),
child: _isLoading ? CircularProgressIndicator() : RaisedButton(
color: Colors.red,
onPressed: ()
async {
if(_formkey.currentState.validate())
{
print('Login Form Vaildated');
setState(() {
_isLoading = true;
});
try {
print('Going to login');
await Utils.login(usernameController.text, passController.text);
Future.delayed(const Duration(seconds: 7)).then((_){
print('Inside Delayed');
Navigator.of(context)
.pushReplacement(MaterialPageRoute(builder: (_) {
return DataEntryScreen(userName:Utils.email,);
}));
setState(() {
_isLoading = false;
});
});
} on HttpException catch(error){
print('Inside HTTP Exp');
var errorMessage = 'Authentication failed';
if (error.toString().contains('EMAIL_EXISTS')) {
errorMessage = 'This email address is already in use.';
} else if (error.toString().contains('INVALID_EMAIL')) {
errorMessage = 'This is not a valid email address';
} else if (error.toString().contains('WEAK_PASSWORD')) {
errorMessage = 'This password is too weak.';
} else if (error.toString().contains('EMAIL_NOT_FOUND')) {
errorMessage = 'Could not find a user with that email.';
} else if (error.toString().contains('INVALID_PASSWORD')) {
errorMessage = 'Invalid password.';
}
setState(() {
_isLoading = false;
});
_showErrorDialog(errorMessage);
print(errorMessage);
} catch(error){
const errorMessage ='Could not authenticate you. Please try again later.';
_showErrorDialog(errorMessage);
setState(() {
_isLoading = false;
});
}
}
},
child: Text(
'Sign in',
style: TextStyle(color: Colors.white),
),
),
)
【问题讨论】:
-
请分享flutter医生的结果