Firebase Sign in / Sign up
I've seen the awesone job you did on the authentication process. However, with the FormState event "isFailure" we can't really notify the user about the kind of error that occured (email already used, no internet connection, etc)
Feature requested:
How to get the exception thrown when "isFailure" return "true"?
Thanks for your help.
Hi @Rickem,
I implemented this by wrapping the type of error in a state. Here an example of it for a create account bloc:
enum SignupErrorType {
NAME,
SURNAME,
EMAIL,
EMAIL_USE,
NICKNAME,
NICKNAME_USE,
USER_CREATION,
NETWORK_ERROR
}
class SignupError extends SignupState {
SignupErrorType errorType;
SignupError({@required this.errorType}):
assert(errorType != null);
@override
String toString() => "Signup error";
}
And then in the UI, I use it as follow:
String _getError(SignupState state) {
if (state is SignupError) {
if (state.errorType == SignupErrorType.EMAIL) {
return Texts.of(context).textOf("signup_email_invalid_error");
}
if (state.errorType == SignupErrorType.EMAIL_USE) {
return Texts.of(context).textOf("signup_email_exists_error");
}
if (state.errorType == SignupErrorType.NETWORK_ERROR) {
return Texts.of(context).textOf("generic_network_error");
}
}
return
}
Mapping of course the proper state and text to your UI.
Hi, @droidpl, thanks for the tip. I really appreciate.
You're welcome. Here to help. Maybe this can be closed @Rickem @felangel
Thanks @Rickem for opening the issue and thanks @droidpl for the awesome answer 馃挴馃憤
Most helpful comment
Hi @Rickem,
I implemented this by wrapping the type of error in a state. Here an example of it for a create account bloc:
And then in the UI, I use it as follow:
Mapping of course the proper state and text to your UI.