在下面的这段代码中,当list is empty
为假时,我尝试显示snapshot.hasData
消息
body: FutureBuilder(
future: Provider.of<TicketRepliesTableDao>(context).find(ticketId: _ticket.id),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasData) {
final List<TicketRepliesTableData> ticketReplies = snapshot.data;
if (ticketReplies.isNotEmpty) {
}
} else {
return _loader(message: 'list is empty');
}
} else
return CircularProgressIndicator();
},
),
但是鉴于这一点,我仍然CircularProgressIndicator()
始终没有任何数据并且ticketReplies
为空
答案 0 :(得分:1)
使用此逻辑更新您的builder
。
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasData) {
// show your data
return Text(snapshot.data);
} else {
// show list is empty
return Text("List is empty");
}
}
// by default show loading bar
return CircularProgressIndicator();
}