i am working on the creation/log for a user but i have multiple error, here is my code, and after my error : LoginController.dart :
String? _mail;
String? _password;
String? _prenom;
String? _nom;
_handlelog(){
if(_mail != null){
if(_password != null){
if(_log == true){
//se connecter
FirebaseHelper().handleSignIn(_mail, _password).then(((User user) {
print("Nous avons un user");
})).catchError((error){
alerte(error.toString());
});
}else{
if(_prenom != null){
if(_nom != null){
//créer un compte avec les données de l'utilisateur
FirebaseHelper().handleCreate(_mail, _password, _prenom, _nom).then(((User user) {
print("Nous avons pu créer un user");
})).catchError((error){
alerte(error.toString());
});
}else{
//Alert nom
alerte("veuillez entrer un nom pour continuer");
}
}else{
//Alert prenom
alerte("veuillez entrer un prenom pour continuer");
}
}
}else{
//Alert password
alerte("le mot de passe est vide");
}
}else{
//Alert mail
alerte("l'adresse mail est vide");
}
}
FirebaseHelper.dart :
class FirebaseHelper {
//Authentification
final auth = FirebaseAuth.instance;
Future<UserCredential> handleSignIn(String mail, String password) async{
final UserCredential user = await auth.signInWithEmailAndPassword(email: mail, password: password);
return user;
}
Future<UserCredential> handleCreate(String mail, String password, String prenom, String nom) async{
final UserCredential credential = await FirebaseAuth.instance.createUserWithEmailAndPassword(email: mail, password: password);
String uid = credential.user!.uid;
Map<String, String> map = {
"uid" : uid,
"prenom" : prenom,
"nom" : nom,
};
addUser(uid, map);
return credential;
}
//database
static final base = FirebaseDatabase.instance.reference();
// ignore: non_constant_identifier_names
final base_user = base.child("users");
addUser(String uid, Map map){
base_user.child(uid).set(map);
}
}
In LoginController.dart i have
The argument type 'String?' can't be assigned to the parameter type 'String'.
The argument type 'Null Function(User)' can't be assigned to the parameter type 'FutureOr<dynamic> Function(UserCredential)'.
I don't know what i can do, i search very long time on docs, on this website for found more detail, but i found nothing, i'm despair