Android studio 在生成过程中调用setState()或markNeedsBuild()

Android studio 在生成过程中调用setState()或markNeedsBuild(),android-studio,flutter,dart,Android Studio,Flutter,Dart,如果应用程序首次使用FutureBuilder()启动,我将尝试启动“如何使用”屏幕 isFirstTime()如果应用程序是第一次启动,则返回true 以下是FutureBuilder代码: body: FutureBuilder( future: isFirstTime(), initialData: Container(), builder: (context, snapshot){ if(snapshot.data == true){

如果应用程序首次使用
FutureBuilder()
启动,我将尝试启动“如何使用”屏幕

isFirstTime()
如果应用程序是第一次启动,则返回true

以下是
FutureBuilder
代码:

body: FutureBuilder(
    future: isFirstTime(),
    initialData: Container(),
    builder: (context, snapshot){

      if(snapshot.data == true){

        Navigator.pushNamed(context, '/howtouse');
        return (currentScreen == 'Home')
            ? HomeBody()
            : CBook(changeScreen: changeCurrentScreen);

      }
      else {

        return (currentScreen == 'Home')
            ? HomeBody()
            : CBook(changeScreen: changeCurrentScreen);
      }

    },
  ),

请提供帮助

在生成过程中无法推送新路由。将逻辑移到initState

@override
void initState() {
  isFirstTime().then((data) {
    if(data) {
      Navigator.pushNamed(context, '/howtouse');
    }
  }
  super.initState();
}

这很有效,非常感谢!