Reputation: 435
I have a Login/sign up page that is connected to firebase. When the user tries to log in with an incorrect account/password, there is a switch case
nestled in the catch
that catches and prints the appropriate error to the console.
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');
I would like to add a return
statement with a String
that can be used in a Text
widget to display to the user an appropriate message.
The try catch is in a validate/submit class that is called when the user selects to Login/Sign up.
I could add more code if it would help. Thanks
Upvotes: 0
Views: 736
Reputation: 543
You can call "setState" inside the catch.
setState(() {
/* update a variable to track the state of the error */
});
Upvotes: 1