I'm using reactive_forms in Flutter which is a model-driven forms library which takes inspiration from Angular Reactive Forms.
It is fairly simple, to add a form with one formControl called 'nickName':
final _form = FormGroup({
'nickName':
FormControl<String>(validators: [Validators.required]),
});
My question is, isn't it commonly done and good practice to have the form control "nickName" be bound to a property of a domain model? As this is what is done in another codebase that I have worked on in Angular.
I do have a domain model for this form (although it has more fields than the form contains. The rest of the fields are set in forms on the following pages - like a setup wizard):
class UserRegistrationEntity {
String nickName;
String email;
String confirmEmail;
String password;
String confirmPassword;
}
I can create the model like so:
final userRegistration = UserRegistrationEntity();
But how can I now bind the nickName field of userRegistration to my form control? I was expecting the form library to have an equivalent to ngModel field for me to set the field of my model on a form control.
Or is this just not something that is done in Flutter?
example: https://angular.io/api/forms/NgModel#using-ngmodel-on-a-standalone-control