小编pru*_*ati的帖子

如何在flutter中获取firestore文档的documentid?

我尝试了以下操作,但它返回一个随机字符串,该字符串不存在于 firestore 中。

我确实设法使用查询快照获取了父集合的文档 ID

DocumentReference doc_ref=Firestore.instance.collection("board").document(doc_id).collection("Dates").document();

                    var doc_id2=doc_ref.documentID;
Run Code Online (Sandbox Code Playgroud)

更多代码:我在尝试访问文档 ID 时遇到错误。我尝试使用 await 但它给出了错误。

 Widget build(BuildContext context) {
        return Scaffold(
          appBar: new AppBar(
            title: new Text(
              "National Security Agency",
              style: TextStyle(
                  color: Colors.black,
                  fontWeight: FontWeight.normal,
                  fontSize: 24.0),
            ),
            backgroundColor: Colors.redAccent,
            centerTitle: true,
            actions: <Widget>[
              new DropdownButton<String>(
                items: <String>['Sign Out'].map((String value) {
                  return new DropdownMenuItem<String>(
                    value: value,
                    child: new Text(value),
                  );
                }).toList(),
                onChanged: (_) => logout(),
              )
            ],
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () {
    
            },
            child: Icon(Icons.search),
          ),
    
          body: StreamBuilder ( …
Run Code Online (Sandbox Code Playgroud)

dart firebase flutter google-cloud-firestore

10
推荐指数
4
解决办法
2万
查看次数

标签 统计

dart ×1

firebase ×1

flutter ×1

google-cloud-firestore ×1