PinInputTextFormField constructor

PinInputTextFormField(
  1. {Key key,
  2. TextEditingController controller,
  3. String initialValue,
  4. int pinLength = _kDefaultPinLength,
  5. ValueChanged<String> onSubmit,
  6. PinDecoration decoration = _kDefaultDecoration,
  7. List<TextInputFormatter> inputFormatters,
  8. TextInputType keyboardType = TextInputType.phone,
  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. @Deprecated("'autovalidate' is deprecated and shouldn't be used, use 'autovalidateMode' instead") bool autovalidate = false,
  16. AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  17. ValueChanged<String> onChanged,
  18. TextCapitalization textCapitalization,
  19. bool autocorrect = false,
  20. bool enableInteractiveSelection = false,
  21. ToolbarOptions toolbarOptions,
  22. Iterable<String> autofillHints,
  23. Cursor cursor}
)

Implementation

PinInputTextFormField({
  Key key,
  this.controller,
  String initialValue,
  this.pinLength = _kDefaultPinLength,
  ValueChanged<String> onSubmit,
  PinDecoration decoration = _kDefaultDecoration,
  List<TextInputFormatter> inputFormatters,
  TextInputType keyboardType = TextInputType.phone,
  FocusNode focusNode,
  bool autoFocus = false,
  TextInputAction textInputAction = TextInputAction.done,
  bool enabled = true,
  FormFieldSetter<String> onSaved,
  FormFieldValidator<String> validator,
  @Deprecated("'autovalidate' is deprecated and shouldn't be used, use 'autovalidateMode' instead")
      bool autovalidate = false,
  AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  ValueChanged<String> onChanged,
  TextCapitalization textCapitalization,
  bool autocorrect = false,
  bool enableInteractiveSelection = false,
  ToolbarOptions toolbarOptions,
  Iterable<String> autofillHints,
  Cursor cursor,
})  : assert(initialValue == null || controller == null),
      assert(autovalidateMode != null),
      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 < pinLength) {
                if (pinLength - value.length > 1) {
                  return 'Missing ${pinLength - value.length} digits of input.';
                } else {
                  return 'Missing last digit of input.';
                }
              }
            }
            return result;
          },
          // FIXME: remove deprecated field in near future
          // ignore: deprecated_member_use, deprecated_member_use_from_same_package
          autovalidate: autovalidate,
          autovalidateMode: autovalidateMode,
          enabled: enabled,
          builder: (FormFieldState<String> field) {
            final _PinInputTextFormFieldState state = field;
            return PinInputTextField(
              pinLength: pinLength,
              onSubmit: onSubmit,
              decoration: decoration.copyWith(errorText: field.errorText),
              inputFormatters: inputFormatters,
              keyboardType: keyboardType,
              controller: state._effectiveController,
              focusNode: focusNode,
              autoFocus: autoFocus,
              textInputAction: textInputAction,
              enabled: enabled,
              onChanged: onChanged,
              textCapitalization: textCapitalization,
              enableInteractiveSelection: enableInteractiveSelection,
              autocorrect: autocorrect,
              toolbarOptions: toolbarOptions,
              autofillHints: autofillHints,
              cursor: cursor,
            );
          });