【发布时间】:2020-12-04 11:00:18
【问题描述】:
我一直在使用 Firestore,并且成功实施了它。但是,当我离线测试它时,旨在实现一个相应的 UI 显示当时无法访问服务器或任何东西,我不断收到 客户端离线 错误,并且由于某种原因,我没办法抓住它。
这是错误信息:
Exception has occurred.
PlatformException (PlatformException(Error performing get, Failed to get document because the client is offline., null))
这也是我的示例代码:
DocumentReference ref = firestoreDb.collection('collection').document('doc1');
try{
ref.get().then((DocumentSnapshot ds){
if(ds.exists == true){
print('ds exists');
}else{
print('ds does not exist);
}
}).catchError((err){
print(err);
});
} on PlatformException catch (err){
print(err);
} catch (err){
print(err);
}
我们绕过了示例代码中的任何错误捕获,并且实际上并未捕获到错误。我需要至少捕获 client is offline 异常,以便正确更新我的 UI。
【问题讨论】:
标签: firebase flutter google-cloud-firestore