PasswordInputTextFormField constructor

PasswordInputTextFormField({
  1. Key? key,
  2. TextEditingController? controller,
  3. String? initialValue,
  4. required int passwordLength,
  5. ValueChanged<String>? onSubmit,
  6. PasswordDecoration decoration = const BoxLooseDecoration(),
  7. List<TextInputFormatter>? inputFormatter,
  8. TextInputType keyboardType = TextInputType.text,
  9. FocusNode? focusNode,
  10. bool autoFocus = false,
  11. TextInputAction textInputAction = TextInputAction.done,
  12. bool enabled = true,
  13. FormFieldSetter<String>? onSaved,
  14. FormFieldValidator<String>? validator,
  15. AutovalidateMode autovalidate = AutovalidateMode.disabled,
  16. ValueChanged<String>? onChanged,
})

Implementation

PasswordInputTextFormField({
  Key? key,
  this.controller,
  this.initialValue,
  required this.passwordLength,
  ValueChanged<String>? onSubmit,
  PasswordDecoration decoration = const BoxLooseDecoration(),
  List<TextInputFormatter>? inputFormatter,
  TextInputType keyboardType = TextInputType.text,
  FocusNode? focusNode,
  bool autoFocus = false,
  TextInputAction textInputAction = TextInputAction.done,
  bool enabled = true,
  FormFieldSetter<String>? onSaved,
  FormFieldValidator<String>? validator,
  AutovalidateMode autovalidate = AutovalidateMode.disabled,
  ValueChanged<String>? onChanged,
})  : assert(initialValue == null || controller == null),
      assert(passwordLength > 0),
      super(
          key: key,
          initialValue:
              controller != null ? controller.text : (initialValue ?? ''),
          onSaved: onSaved,
          validator: (value) {
            var result = validator!(value);
            if (result == null) {
              if (value!.isEmpty) {
                return 'Input field is empty.';
              }
              if (value.length < passwordLength) {
                if (passwordLength - value.length > 1) {
                  return 'Missing ${passwordLength - value.length} digits of input.';
                } else {
                  return 'Missing last digit of input.';
                }
              }
            }
            return result;
          },
          autovalidateMode: autovalidate,
          enabled: enabled,
          builder: (FormFieldState<String> field) {
            final _PasswordInputTextFormFieldState state =
                field as _PasswordInputTextFormFieldState;
            return PasswordInputTextField(
              passwordLength: passwordLength,
              onSubmit: onSubmit,
              decoration:
                  decoration.copyWith(errorText: field.errorText ?? ''),
              inputFormatter: inputFormatter,
              keyboardType: keyboardType,
              controller: state._effectiveController,
              focusNode: focusNode,
              autoFocus: autoFocus,
              textInputAction: textInputAction,
              enabled: enabled,
              onChanged: onChanged,
            );
          });