The point is that if we use the copyWith method, as in the example below, it creates a new object, and what happens to the old one?
If the old one is not deleted, doesn't this lead to a loss of performance?
The CopyWith method is usually used in statenotifier in this case, isn't it better to use a changenotifier instead of a statenotifier in terms of performance?
class EmailSignInModel {
EmailSignInModel({
this.email='',
this.formType=EmailSignInFormType.signIn,
this.isLoading=false,
this.password='',
this.submitted=false,
});
final String email;
final String password;
final EmailSignInFormType formType;
final bool isLoading;
final bool submitted;
EmailSignInModel copyWith({
String email,
String password,
EmailSignInFormType formType,
bool isLoading,
bool submitted,
}) {
return EmailSignInModel(
email: email ?? this.email,
password: password?? this.password,
formType: formType?? this.formType,
isLoading: isLoading?? this.isLoading,
submitted: submitted?? this.submitted
);
}
}