相关疑难解决方法(0)

从Flutter的Firestore集合中获取所有内容

我在我的项目中设置了Firestore.我创建了名为的新集合categories.在这个集合中,我使用uniq id创建了三个文档.现在我想在我的Flutter应用程序中获取此集合,因此我创建了CollectionReference:

Firestore.instance.collection('categories')
Run Code Online (Sandbox Code Playgroud)

但我不知道接下来会发生什么.

我正在使用这个插件 firebase_firestore: 0.0.1+1

dart firebase flutter google-cloud-firestore

8
推荐指数
7
解决办法
1万
查看次数

如何在flutter中从firebase获取数据

我正在构建一个 flutter 应用程序并使用 cloud-firestore,这就是我的数据库的样子 在此处输入图片说明

我想要一个函数,它在一个字符串数组中检索名为“驱动程序列表”的集合中的所有文档,这些文档是我已经使用过的,但它会将它们返回到新屏幕的列表视图中

class DriverList extends StatelessWidget {@overrideWidget build(BuildContext context) {
return new StreamBuilder<QuerySnapshot>(
  stream: Firestore.instance.collection('DriverList').snapshots(),
  builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
    if (!snapshot.hasData) return new Text('Loading...');
    return new ListView(
      children: snapshot.data.documents.map((DocumentSnapshot document) {
        return new ListTile(
          title: new Text(document['name']),
          subtitle: new Text(document['phone']),
        );
      }).toList(),
    );
  },
);
Run Code Online (Sandbox Code Playgroud)

} }

dart firebase flutter google-cloud-firestore

8
推荐指数
2
解决办法
3万
查看次数

标签 统计

dart ×2

firebase ×2

flutter ×2

google-cloud-firestore ×2