【发布时间】:2021-02-21 18:31:13
【问题描述】:
我正在使用 Flutter 和 Firebase 来制作待办事项列表。即使在我检查了我的 snap.data == null 之后,它仍然向我显示此错误。但我不确定为什么仍然不起作用。
请帮忙。我检查过类似的问题,但仍然没有解决 对不起我的英语
body: StreamBuilder(
stream: Firestore.instance.collection("MyTodos").snapshots(),
builder: (context, snapshots) {
return ListView.builder(
shrinkWrap: true,
itemCount: snapshots.data.documents.length,
itemBuilder: (context, index) {
DocumentSnapshot documentSnapshot =
snapshots.data.documents[index];
return Dismissible(
key: Key(index.toString()),
child: Card(
child: ListTile(
title: Text(documentSnapshot["todoTitle"]),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () {
setState(() {
todos.removeAt(index);
});
},
),
),
),
);
},
);
},
)
【问题讨论】:
-
你检查过连接状态吗?
-
不,我该怎么做?
-
我猜你已经找到了答案。但我会把它留作参考AsyncSnapshot
-
谢谢你的提及????
标签: flutter dart stream-builder