This will help you to add a loading screen till values load. if not you need to use await.
Widget futureBuilder() {
return FutureBuilder<List<Project>>(
future: _getBooks(),
builder: (context, snapshot) {
debugPrint('Builder');
switch (snapshot.connectionState) {
case ConnectionState.done:
if (snapshot.hasError)
return new Text('Error: ${snapshot.error}');
else
return listWidget(snapshot);
break;
default:
debugPrint("Snapshot " + snapshot.toString());
return Container() // also check your listWidget(snapshot) as it may return null.
}
},
);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…