在按钮onPressed方法中,我试图从提供程序中清除变量,然后转到另一页。
Provider.of<MyProvider>(context, listen: false).clearSomeVar());
Navigator.of(context).pushNamedAndRemoveUntil('/anotherRoute', (route) => false);
在构建器中同一页面上的其他小部件中,我具有以下内容:
if (someVar == null) {
Navigator.of(context).pushNamedAndRemoveUntil('/coolPage', (route) => false);
return Container();
}```
The screen goes red for a second, and I get the following error:
> setState() or markNeedsBuild() called during build.