I write this class
class Profile {
String email;
String password;
Profile({this.email, this.password});
}
But it said that
"The parameter 'email' can't have a value of 'null' because of its type, but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.dartmissing_default_value_for_parameter"
CodePudding user response:
By adding required:
class Profile {
String email;
String password;
Profile({
required this.email,
required this.password,
});
}
By adding optional:
class Profile {
String? email;
String? password;
Profile({
this.email,
this.password,
});
}
By adding default values:
class Profile {
String email;
String password;
Profile({
this.email = "[email protected]",
this.password = "123",
});
}
CodePudding user response:
You have to make them accept a null
value.
class Profile {
String? email;
String? password;
Profile({this.email, this.password});
}