【发布时间】:2021-12-09 16:42:29
【问题描述】:
我正在尝试从我的收藏“课程”2 字段中检索。 课程代码和课程名称。检索时的问题是我只设法检索了第一个字段。
builder: (context, snapshot) {
if (snapshot.hasData) {
return ListView.separated(
itemCount: snapshot.data!.docs.length,
separatorBuilder: (BuildContext context, int index) =>
Divider(height: 1),
// ignore: dead_code
itemBuilder: (context, index) {
DocumentSnapshot doc = snapshot.data!.docs[index];
return ListTile(
contentPadding:
EdgeInsets.symmetric(horizontal: 30, vertical: 10),
selectedTileColor: Color(0xffE5E5E5),
title: Text.rich(
TextSpan(
text: doc["Course code"],
children: <TextSpan>[
TextSpan(text: ":"),
TextSpan(text: doc["Course name"]),
它向我显示了这个错误:
Exception has occurred.
StateError (Bad state: field does not exist within the DocumentSnapshotPlatform)
我只能检索课程代码,不知道为什么。
【问题讨论】:
-
如果上述文档对您有帮助,请告诉我们?
标签: firebase flutter dart google-cloud-firestore