简体   繁体   English

试图处理 firebase 存储异常不起作用(颤振)

[英]trying to handle firebase storage exception doesn't work (flutter)

After creating the reference to my file on firebase storage I'm getting it's download URL.在 firebase 存储上创建对我的文件的引用后,我正在下载 URL。 Since the file(image) may or may not exist I'm using then and catch error .由于文件(图像)可能存在也可能不存在,因此我正在使用then捕获错误 However it still throws exception.但是它仍然抛出异常。 Even the try and catch block doesn't work.即使是 try and catch 块也不起作用。

    StorageReference dpRef = FirebaseStorage.instance.ref().child(
          'dp/' + widget.userId,
        );
    dpRef.getDownloadURL().then(
      (value) {
        setState(
          () {
            _dpImgURL = value;
          },
        );
      },
    ).catchError((e) {
      print(e.toString());
    });

What am I doing wrong?我究竟做错了什么? New to flutter, so please be gentle. flutter 的新手,所以请温柔。

try catch is not working for firebase storage, no idea why, i fixed like this: try catch 不适用于 firebase 存储,不知道为什么,我这样修复:

}, onError: (e) {
      debugPrint('Exception::: ==========>>>>>>> ${e.toString()}');
      status(null);
    });

it gets the exception vey well它很好地得到了异常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在尝试使用 Firebase 在 Flutter 中使用 Google 注销,但它不起作用 - I'm trying to signOut with google in Flutter with Firebase and it doesn't work Flutter Firebase 存储 - 当文件不存在时隐藏存储异常 - Flutter Firebase Storage - Hide Storage Exception when a file doesn't exist firebase 存储规则不起作用 - firebase storage rule doesn't work Flutter Firebase GoogleSignIn 在发行版中不起作用 - Flutter Firebase GoogleSignIn doesn't work in release Firebase存储:child()不适用于iOS App - Firebase Storage: child() doesn't work with iOS App Firebase 存储 listAll() 和 getDownloadURL() 不起作用 - Firebase Storage listAll() together with getDownloadURL() doesn't work out "Flutter Firebase Google Auth 在生产中不起作用" - Flutter Firebase Google Auth doesn't work in production Flutter - Firebase onLaunch 中的云消息导航不起作用 - Flutter - Firebase Cloud Messaging Navigation in onLaunch doesn't work .once() 在使用 Flutter 和 Firebase 时似乎不起作用/无法识别 - .once() doesn't seem to work / recognized while working with Flutter & Firebase Firebase 因无效安全(DART/FLUTTER)而不起作用 - Firebase doesn't work cause of null-safety (DART/FLUTTER)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM