buildForm method
Implementation
FormGroup buildForm(ComplaintsRegistrationState state) {
final addressModel = state.mapOrNull(
view: (value) => value.addressModel,
);
final shouldDisableForm = addressModel != null;
return fb.group(<String, Object>{
_addressLine1Key: FormControl<String>(
value: addressModel?.buildingName,
disabled: shouldDisableForm,
validators: [
Validators.delegate(
(validator) => CustomValidator.requiredMin(validator)),
Validators.maxLength(maxLength),
],
),
_addressLine2Key: FormControl<String>(
value: addressModel?.street,
disabled: shouldDisableForm,
validators: [
Validators.delegate(
(validator) => CustomValidator.requiredMin(validator)),
Validators.maxLength(maxLength),
],
),
_landmarkKey: FormControl<String>(
value: addressModel?.landmark,
disabled: shouldDisableForm,
validators: [
Validators.delegate(
(validator) => CustomValidator.requiredMin(validator)),
Validators.maxLength(maxLength),
],
),
_postalCodeKey: FormControl<String>(
value: addressModel?.pincode,
disabled: shouldDisableForm,
validators: [
Validators.delegate(
(validator) => CustomValidator.requiredMin(validator)),
Validators.maxLength(6),
],
),
_latKey: FormControl<double>(
value: addressModel?.geoLocation?.latitude,
validators: [
Validators.delegate(
(validator) => CustomValidator.requiredMin(validator)),
],
),
_lngKey: FormControl<double>(
value: addressModel?.geoLocation?.longitude,
),
_accuracyKey: FormControl<double>(),
});
}