我想处理 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.');
}
}
},
),
这里一切正常,但我想显示错误消息而不是将它们放在控制台中。我该怎么做?