I'm trying to use Google's Firebase Authentication in my flutter application. However, when handling user's login, I cannot seem to find a "code" to differentiate the types of exceptions for me to handle.
Loginhandler.dart:
class LoginHandler {
String signup(_username, _password) async {
bool _valid = false;
final prefs = await SharedPreferences.getInstance();
FirebaseAuth.instance.createUserWithEmailAndPassword(
email: _username, password: _password)
.catchError((e) {
print(e);
print(e.message);
print(e.code);
print(e.details);
});
...
Error outputs:
W/BiChannelGoogleApi(26738): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@4e727e7
W/IInputConnectionWrapper(26738): getCursorCapsMode on inactive InputConnection
I/flutter (26738): PlatformException(exception, The email address is already in use by another account., null)
I/flutter (26738): The email address is already in use by another account.
I/flutter (26738): exception
I/flutter (26738): null
I/flutter (26738): PlatformException(exception, The given password is invalid. [ Password should be at least 6 characters ], null)
I/flutter (26738): The given password is invalid. [ Password should be at least 6 characters ]
I/flutter (26738): exception
I/flutter (26738): null
I have followed this Stack Overflow thread which highlights I can use a switch statement, but the above error output have no error "codes" for me to work with.