我尝试使用 bool 查询 cloudfirestore 上是否存在文档。不幸的是,我的代码不起作用
我尝试了以下操作,但 bool 没有改变。
getok() {
bool ok;
Firestore.instance.document('collection/$name').get().then((onexist){
onexist.exists ? ok = true : ok = false;
}
);
if (ok = true) {
print('exist');
} else {
print('Error');
}
}
Run Code Online (Sandbox Code Playgroud)