flutter - 处理 Firebase_Auth 错误并在屏幕上显示错误
问题描述
我想处理 firebase_auth 异常并在屏幕上显示错误消息。我有几个关于在屏幕上显示错误消息的问题。
- 有什么东西可以自动显示消息吗?
- 还是我需要提供文本字段或标签来显示消息?
我正在使用最新的软件包:firebase_auth: ^3.0.1
这是我的登录代码:
RoundedButton(
title: 'Log In',
colour: Colors.lightBlueAccent,
onPressed: () async {
setState(() {
showSpinner = true;
});
try {
UserCredential userCredential = await _auth.signInWithEmailAndPassword(email: email, password: password);
} on FirebaseAuthException catch (e) {
if (e.code == 'user-not-found') {
print('No user found for that email.');
} else if (e.code == 'wrong-password') {
print('Wrong password provided for that user.');
}
}
},
),
这里一切正常,但我想显示错误消息而不是将它们放在控制台中。我该怎么做呢?
解决方案
推荐阅读
- python - 打印函数中的双变量可能的矩阵运算
- angular - 找不到模块“流浏览器”
- c# - 控制 MouseWheel 事件时滚动导致闪烁
- django - 我如何在 django 中使用 ModelChoiceField(queryset=...) 从选项中获取选定的值
- php - 如何将codeigniter 2x版本升级到3x
- sql - MS Access 字符串替换查询
- text - 如何在一长行中每 3 个字符后创建一个换行符?
- laravel - Laravel SVG 文件验证不接受 svg 文件
- maven - 需要在我的 selenium 黄瓜项目中使用 serenity bdd 生成报告
- java-8 - 多个@EnsuresNonNullIf 应该没问题;但编译器抱怨