我尝试使用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');
}
}