【发布时间】:2021-02-12 15:50:37
【问题描述】:
我正在尝试在 Flutter 上使用 Firebase 身份验证在我的应用上创建登录功能。
我必须处理许多异常,但我根本无法捕获它们。
这是我的代码。
Future<void> onSubmitted(
String email, AnimationController controller, BuildContext context) async {
controller.repeat();
FirebaseAuth _auth = FirebaseAuth.instance;
try {
_auth.signInWithEmailAndPassword(email: email, password: "1");
} on PlatformException catch (e) {
debugPrint(e.toString());
} on FirebaseAuthException catch (e) {
debugPrint(e.toString());
}
}
这是用于测试的简化形式。无论如何,它甚至没有达到 catch 语句。它在到达 catch 语句之前引发 PlatformException。我不明白。
错误码是这样的。
未处理的异常:[firebase_auth/user-not-found] 没有与此标识符对应的用户记录。该用户可能已被删除。
我明确指定了异常的类型,它应该打印错误消息,但它甚至没有到达 debugPrint() 函数。
我应该如何捕捉异常?
【问题讨论】:
标签: flutter dart firebase-authentication