Is there a way to load async data on InitState method?

前端 未结 9 1524
你的背包
你的背包 2020-12-05 16:39

I\'m a looking for a way to load async data on InitState method, I need some data before build method runs. I\'m using a GoogleAuth code, and I need to execute build method

9条回答
  •  温柔的废话
    2020-12-05 17:21

      @override
      void initState() {
        super.initState();
        asyncInitState(); // async is not allowed on initState() directly
      }
    
      void asyncInitState() async {
        await yourAsyncCalls();
      }
    

提交回复
热议问题