Firebase 如何从异常try catch中返回和显示错误消息
我有一个连接到firebase的登录/注册页面。当用户尝试使用不正确的帐户/密码登录时,Firebase 如何从异常try catch中返回和显示错误消息,firebase,flutter,dart,Firebase,Flutter,Dart,我有一个连接到firebase的登录/注册页面。当用户尝试使用不正确的帐户/密码登录时,catch中有一个开关盒,该开关盒捕捉并将相应的错误打印到控制台 on PlatformException catch (e) { if (Platform.isAndroid) { switch (e.message) { case 'There is no user record corresponding to this identifier. The user ma
catch
中有一个开关盒
,该开关盒捕捉并将相应的错误打印到控制台
on PlatformException catch (e) {
if (Platform.isAndroid) {
switch (e.message) {
case 'There is no user record corresponding to this identifier. The user may have been deleted.':
errorType = authProblems.UserNotFound;
break;
}
print('The error is $errorType');
我想添加一个带有字符串的return
语句,该语句可以在文本
小部件中使用,以向用户显示适当的消息
try catch位于用户选择登录/注册时调用的validate/submit类中
如果有帮助的话,我可以添加更多的代码。谢谢您可以在catch内调用“setState”
setState(() {
/* update a variable to track the state of the error */
});