我的应用程序从 Firebase 存储获取图像。如果不存在图像,我希望能够处理该错误。但我似乎无法让它发挥作用。
\n\n我尝试过用 try catch 包围。
\n\n我试过这个
\n\nFuture<dynamic> getImage(int index){\n return FirebaseStorage.instance.ref().child(widget.snap[index].data[\'\xe8\x8b\xb1\xe6\x96\x87\xe5\x93\x81\xe5\x90\x8d\']+".jpg").getDownloadURL().catchError((onError){\n print(onError);\n }); \n }\nRun Code Online (Sandbox Code Playgroud)\n\n和这个
\n\n Future<dynamic> getImage(int index){\n var imageStream;\n try {\n imageStream = FirebaseStorage.instance.ref().child(widget.snap[index].data[\'\xe8\x8b\xb1\xe6\x96\x87\xe5\x93\x81\xe5\x90\x8d\']+".jpg").getDownloadURL(); \n } catch (e) {\n print(e);\n }\n return imageStream;\n }\nRun Code Online (Sandbox Code Playgroud)\n\n但我总是遇到未处理的异常错误并且我的应用程序崩溃。
\n\nE/StorageException(11819): StorageException has occurred.\nE/StorageException(11819): Object does not exist at location.\nE/StorageException(11819): Code: -13010 HttpResult: 404\nE/StorageException(11819): StorageException has occurred.\nE/StorageException(11819): Object does not exist at location.\nE/StorageException(11819): Code: -13010 HttpResult: 404\nE/StorageException(11819): { "error": { "code": 404, "message": "Not …Run Code Online (Sandbox Code Playgroud)