【发布时间】:2021-09-07 06:52:57
【问题描述】:
我希望用户在我的应用中提供一个值,并让其他用户看到它。但是我可以将数据上传到firebase,但不能在另一边获取。我在颤振上启用了空安全。代码是:-
child: StreamBuilder(
stream:FirebaseFirestore.instance.collection('Collection name').doc('doc id').snapshots()
builder: (context, snapshot){
if(snapshot.hasData){
return Text(snapshot.data['Field name'].toString()); // here my editor shows error saying 'The method '[]' can't be unconditionally invoked because the receiver can be 'null'.' and asks for a null check and then shows error again
}
return Text('Nothing');
}
),
编辑:我得到的只有 'type '_JsonDocumentSnapshot' is not a subtype of type 'Map
如果我改变了
if(snapshot.hasData){
return Text(snapshot.data['Field name'].toString());
到
if (snapshot.hasData) {
return Text(snapshot.data.toString());
}
我得到的输出为 '_JsonDocumentSnapshot' 的实例'' 数据应该在哪里。 我正在使用空检查飞镖
【问题讨论】:
-
firebasedb 等于什么?同时分享数据库截图
-
firebasedb 等于 FirebaseFirestore.instacne.collection('collection').snapshot();抱歉,由于可能点的一些问题,我无法获得屏幕截图。 IDK 那是什么,我是新手。那里只有一个文档。我已经更新了请看
标签: flutter google-cloud-firestore