我希望它做什么
我想获取用户在实时更新的个人资料中存储的照片数量的列表。
我希望我的代码从用户个人资料中获取链接,但我不断收到错误消息。
值“ Text(” $ {document ['link']}“)”“为空。
我尝试了什么 阅读并应用有关此问题的stackoverflow的每个问题/解决方案
我的代码 我已经有另一个streambuilder,用于获取实例的名称,因此这就是另一个DocumentSnapshot的来源。现在我只想要一个专注于图片的流构建器。
Widget imageList(DocumentSnapshot document //I use this to fetch the current document ID) {
print(_uploadedFileURL);
return StreamBuilder(
stream: Firestore.instance
.collection('Test')
.document(document.documentID).collection('foto')
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return Text("Loading");
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_imageList(context, snapshot.data.documents[index]));
},
);
}
//Widget to show the Text but this returns null
Widget _imageList(BuildContext context, DocumentSnapshot document) {
return Card(
child: prefix0.Column(
children: <Widget>[
prefix0.Text("${document['link']}")
],
),
);
}