buildForm method

FormGroup buildForm(
  1. BeneficiaryRegistrationState state
)

Implementation

FormGroup buildForm(BeneficiaryRegistrationState state) {
  final addressModel = state.mapOrNull(
    editHousehold: (value) => value.addressModel,
  );

  return fb.group(<String, Object>{
    _administrationAreaKey: FormControl<String>(
      value: localizations.translate(
          RegistrationDeliverySingleton().boundary!.code ?? ''),
      validators: [Validators.required],
    ),
    _addressLine1Key:
        FormControl<String>(value: addressModel?.addressLine1, validators: [
      CustomValidator.requiredMin,
      Validators.maxLength(64),
    ]),
    _addressLine2Key: FormControl<String>(
      value: addressModel?.addressLine2,
      validators: [
        CustomValidator.requiredMin,
        Validators.maxLength(64),
      ],
    ),
    _landmarkKey:
        FormControl<String>(value: addressModel?.landmark, validators: [
      CustomValidator.requiredMin,
      Validators.maxLength(64),
    ]),
    _postalCodeKey:
        FormControl<String>(value: addressModel?.pincode, validators: [
      CustomValidator.requiredMin,
      Validators.maxLength(6),
    ]),
    _latKey: FormControl<double>(value: addressModel?.latitude, validators: [
      CustomValidator.requiredMin,
    ]),
    _lngKey: FormControl<double>(
      value: addressModel?.longitude,
    ),
    _accuracyKey: FormControl<double>(
      value: addressModel?.locationAccuracy,
    ),
  });
}