相关疑难解决方法(0)

在Dart的Cloud Firestore中添加文档后如何获取文档ID

我使用以下代码通过Dart / Flutter更新了Cloud Firestore集合。

  final docRef = Firestore.instance.collection('gameLevels');
  docRef.document().setData(map).then((doc) {
    print('hop');
  }).catchError((error) {
    print(error);
  });
Run Code Online (Sandbox Code Playgroud)

我正在尝试将文档添加到集合中时创建的documentID,但(doc)参数返回为null。我以为应该是documentReference?

由于为空,因此我显然不能使用doc.documentID。

我究竟做错了什么?

dart flutter google-cloud-firestore

4
推荐指数
3
解决办法
2741
查看次数

标签 统计

dart ×1

flutter ×1

google-cloud-firestore ×1