您可以使用FutureBuilder解决此问题。
@overrideWidget build(BuildContext context) { new FutureBuilder<String>( future: getLoginState(), builder: (BuildContext context, AsyncSnapshot<String> snapshot) { switch (snapshot.connectionState) { case ConnectionState.active: case ConnectionState.waiting: return new Text('Loading...'); case ConnectionState.done: if (snapshot.hasData) { loginState = snapshot.data; if(loginState) { return Container(child: Text('Logged In')); } else { return Container(child: Text('Not Logged In)); } } else {return Container(child: Text('Error..)); } } }, ) }注意:我们不需要
isLoggedIn状态变量。



