【发布时间】:2020-05-05 07:54:27
【问题描述】:
我正在尝试检测该用户不再经过身份验证并将用户重定向到登录。我就是这样做的
Widget build(BuildContext context) {
return FutureBuilder(
future: _getData(context),
builder: (context, snapshot) {
try {
if (snapshot.hasError && _isAuthenticationError(snapshot.error)) {
Navigator.push(context, MaterialPageRoute(builder: (context) => LoginView()));
}
不幸的是,在构建时进行导航不起作用。它抛出这个错误
flutter: setState() or markNeedsBuild() called during build.
flutter: This Overlay widget cannot be marked as needing to build because the framework is already in the
flutter: process of building widgets. A widget can be marked as needing to be built during the build
我不能只返回 LoginView 小部件,因为父小部件包含应用栏和浮动按钮,并且登录视图需要在没有这些控件的情况下显示。我需要导航。
有可能吗?
【问题讨论】:
-
用户如何登录?是火力基地吗?