Flutter freeze in between views
我的Flutter应用似乎卡在了两个视图之间,login_view和home_view。仅在Android中发生此问题。知道为什么会这样吗?这和我的Android模拟器有关吗?预先谢谢你!
login_view_model.dart
class LoginViewModel extends BaseModel {
final AuthenticationService _authenticationService = locator<AuthenticationService>();
final DialogService _dialogService= locator<DialogService>();
final NavigationService _navigationService = locator<NavigationService>();
Future login ({@required String email, @required String password}) async {
setBusy(true);
var result = await _authenticationService.loginWithEmail(email: email, password: password);
setBusy(false);
if (result is bool) {
if (result) {
_navigationService.navigateTo(HomeViewRoute);
} else {
await _dialogService.showDialog(title: 'Login Failure', description: 'General login failure. Please try again later');
}
} else {
await _dialogService.showDialog(title: 'Login Failure', description: result);
}
}
void navigateToSignUp() {
_navigationService.navigateTo(SignUpViewRoute);
}
}
home_view.dart
class HomeView extends StatelessWidget {
const HomeView({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Center(
child: Text('Home'),
);
}
}
答案 0 :(得分:0)
通常对于每次导航,您的页面都应使用Material(也可以是Material / Scaffold / SafeArea)进行包装