【问题标题】:Flutter - The getter 'message' isn't defined for the type 'Object'颤振 - 没有为“对象”类型定义吸气剂“消息”
【发布时间】:2021-09-23 09:43:34
【问题描述】:

我的消息有错误,我看到每个人都使用它来显示错误,但我只是收到一个错误:getter 'message' 没有为类型 'Object' 定义。

Future<String> logInUserWithEmail(String email, String password) async {
String retVal = 'error';
//code

  retVal = 'success';
} catch (e) {
  retVal = e.message; //<-- this here shows the error
}
return retVal;

} }

他们最近是否更改了它,或者有什么问题?

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    使用以下

    retVal = e.toString() ;

    【讨论】:

    • 我试过了,但它不再显示该消息。
    • 如果发生任何错误,就会执行 catch 块。请告诉我你写这段代码的目的是什么?
    • 显示可能出现的错误,如邮箱已在使用、密码错误等
    • 您在哪里使用该电子邮件是否已使用?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-23
    • 1970-01-01
    • 2021-08-28
    • 1970-01-01
    • 2021-08-05
    • 2021-04-14
    • 2021-09-17
    相关资源
    最近更新 更多