且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

flutter / dart如何检查Firestore中是否存在文档?

更新时间:2023-11-26 09:05:46

you可以尝试这样做,尽管我使用的是IDS

you could try doing it this way though im usi IDS

static Future<bool> checkExist(String docID) async {
    bool exists = false;
    try {
      await Firestore.instance.document("users/$docID").get().then((doc) {
        if (doc.exists)
          exists = true;
        else
          exists = false;
      });
      return exists;
    } catch (e) {
      return false;
    }
  }