Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 如何从异常try catch中返回和显示错误消息_Firebase_Flutter_Dart - Fatal编程技术网

Firebase 如何从异常try catch中返回和显示错误消息

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

我有一个连接到firebase的登录/注册页面。当用户尝试使用不正确的帐户/密码登录时,
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 */
});