Flutter - The getter 'message' isn't defined for the type 'Object'

Viewed 1568

I have an error with messages, i have seen everyone using it for displaying errors, but I just get an error : The getter 'message' isn't defined for the type '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;

} }

Did they change it recently or, what is the issue?

2 Answers

Use following

retVal = e.toString() ;

Related