相关疑难解决方法(0)

如何从flutter中的firestore文档字段获取数据?

我正在尝试在我的 flutter-app 中测试 firestore,但我无法真正按预期加载数据。

这是我获取数据的方式:

 Firestore.instance
        .collection('Test')
        .document('test')
        .get()
        .then((DocumentSnapshot ds) {
      // use ds as a snapshot

      print('Values from db: $ds');
    });
Run Code Online (Sandbox Code Playgroud)

和打印语句输出:flutter: Values from db: Instance of 'DocumentSnapshot'。

我也尝试了以下操作,但没有成功:

Firestore.instance.collection('Test').document('test').get().then((data) {
  // use ds as a snapshot

  if (data.documentID.length > 0) {
    setState(() {
      stackOver = data.documentID;
      print(stackOver);
    });
  }
});
Run Code Online (Sandbox Code Playgroud)

这里的输出只是documentID-name..

那么,我怎么能从 firestore 中获取字段值呢?

此致!

dart firebase flutter google-cloud-firestore

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

标签 统计

dart ×1

firebase ×1

flutter ×1

google-cloud-firestore ×1