【问题标题】:Flutter app is crashing although I wrote it in try catch block尽管我在 try catch 块中编写了 Flutter 应用程序,但它正在崩溃
【发布时间】:2020-09-15 02:56:24
【问题描述】:

我在我的应用程序和登录和处理错误中使用 Firebase Auth 我在 try-catch 块中编写了它,但是当我输入不正确的密码时,应用程序会崩溃并抛出 "PlatformException (PlatformException(ERROR_WRONG_PASSWORD , 密码无效或用户没有密码。, null))" 这个错误。

我该如何解决这个问题?

这是代码,注册用户也是如此。

try {
    final newUser = await _auth.signInWithEmailAndPassword(email: email, password: password);
    if (newUser != null) {
        Navigator.pop(context);
    }
    } catch (e) {
        print(e);
    }

【问题讨论】:

标签: flutter dart try-catch


【解决方案1】:

如果 VSCode 的“所有异常”的解决方案对您不起作用...

请记住,debug 版本可能会引发异常,而 release 版本中的相同代码可能不会。

如果您确定您的代码在 try 块内失败并且您正在正确处理 catch(就像 OP 一样),请尝试使用 flutter run --release 运行您的应用程序并检查它是否有效。

在此处查看此问题/答案以获取更多信息:Flutter catching all unhandled exceptions

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-25
    • 2019-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-17
    相关资源
    最近更新 更多