I have a problem when trying to sign up and enter credentials. I enter a valid email format [email protected], and i get this exception : [firebase_auth/invalid-email] The email address is badly formatted.
here is my method addUser() i implemented:
Future<void> addUser(String nom, String prenom, String matricule, String email,
String motDePasse) async {
try {
await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: email,
password: motDePasse,
);
} catch (e) {
debugPrint(e.toString());
}
}
please help thank you in advance !
im new to flutter, i tried everything i could try.
1
are you sure you’re passing [email protected]
as email? It’s common to have this issue occurred due to extra whitespaces at the end. If that’s the case, you can simply trim
the String and use it.
Try the following code:
Future<void> addUser(String nom, String prenom, String matricule, String email,
String motDePasse) async {
try {
await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: email.trim(), // <- trimmed the string
password: motDePasse,
);
} catch (e) {
debugPrint(e.toString());
}
}
Hope this helps 🙂
0