I got this code to signup user with email and password in firebase. But the problem is that the try seems doesn't work. It keeps display an exception error message even when I have already put catch there.
static Future<FirebaseUser> signUp(String email, String password) async {
try {
AuthResult result = await _auth.createUserWithEmailAndPassword(
email: email, password: password);
FirebaseUser firebaseUser = result.user;
return firebaseUser;
} catch (e) {
print(e.toString());
return null;
}
}