为什么不扑捉Firebase存储文件未找到错误?

在我的flutter应用程序中,我尝试获取Firebase存储中文件的url。我故意删除了该文件,以测试找不到文件时显示给用户的错误消息。问题是Flutter / Dart根本无法捕获错误!而是冻结应用程序,并在Visual Studio代码中显示此异常:

”发生了异常。 PlatformException(PlatformException(download_error,对象在该位置不存在。,null))“

这是我捕获错误的代码:

StorageReference storageReference = FirebaseStorage.instance.ref().child('nonExistingFile.jpg');
storageReference.getDownloadURL().catchError((onError){
  scaffoldKey.currentState.showsnackBar(new snackBar(content: new Text("Error: File not found!"),duration: new Duration(seconds: 4),));
});

以上代码无法捕获错误并采取相应措施!为什么会这样?

nidi_3 回答:为什么不扑捉Firebase存储文件未找到错误?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3071267.html

大家都在问