【发布时间】:2021-04-27 18:18:31
【问题描述】:
我搜索了相同问题的主题,但没有人解决我的问题。
我有这个云存储:
我创建了这个服务:
import 'package:cloud_firestore/cloud_firestore.dart';
class FireBaseApi {
getData() {
try {
var databse = FirebaseFirestore.instance.collection('mycollection');
return databse;
} catch (e) {
print(e);
return null;
}
}
}
并像这样使用它:
return StreamBuilder(
stream: FireBaseApi().getData().snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Scaffold(
body: Center(
child: SizedBox(
width: 100,
height: 100,
child: CircularProgressIndicator())),
);
} else {
print('length = ${snapshot.data.documents}');
return SafeArea(
child: Scaffold(
body: ListView( children: [Text('Noj Clinic'),
child: GridView.builder(
itemCount: snapshot.data.size, .......etc
)],)
我给了错误Class 'QuerySnapshot' has no instance getter 'documents'.
这是显示出来的:
【问题讨论】:
标签: flutter google-cloud-firestore document