firebase - 为什么颤振不捕捉firebase存储文件未找到错误?
问题描述
在我的颤振应用程序中,我尝试在 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),));
});
上面的代码没有捕捉到错误并采取相应的行动!这是为什么??
解决方案
推荐阅读
- redirect - 如何将 Kotlin 标准输出重定向到文件?
- python - Pandas 的 read_csv C 引擎有什么方法可以忽略或替换 Unicode 解析错误?
- python - pytorch:所有类的交叉熵之和
- bash - 如何按作为bash中文件名一部分的数字排序?
- json - 使用 jq 将 JSON 格式转换为 CSV Bash
- f# - F#中的乘法
- python - 在 Jupyter Notebook python 上加载多个图像
- python - Python json.loads 失败并出现错误-“simplejson.errors.JSONDecodeError: Invalid control character '\x00' at: line 1 column 536 (char 535)”
- javascript - 关于如何在 javascript 中为 dom 元素获取一致 xpath 的建议
- python - 分配前引用的 /memberships/payment 局部变量“课程”处的 UnboundLocalError