更新时间:2022-04-07 23:12:57
您应该在initState()
函数中从数据库中获取日期,然后必须修改窗口小部件生成器以使用FutureBuilder
,这是一个示例:
You Should fetch your date from the database in the initState()
function, then you have to modify your widget builder to use FutureBuilder
, here's an example:
Widget build(BuildContext context) {
return FutureBuilder(
future: getProfile(),
builder: (BuildContext context, AsyncSnapshot<SharedPreferences> snapshot) {
if(snapshot.connectionState == ConnectionState.done){
return new MaterialApp();
}
}
)
}
请注意,您可以将AsyncSnapshot<SharedPreferences>
替换为Future
函数返回的类型.
note that you can replace AsyncSnapshot<SharedPreferences>
with the type your Future
function returns.