TextField constructor

TextField({
  1. String? label,
  2. String? name,
  3. TextEditingController? controller,
  4. Object? value,
  5. String? placeholder,
  6. String type = 'text',
  7. bool required = false,
  8. bool disabled = false,
  9. bool readonly = false,
  10. InputVariant variant = InputVariant.outline,
  11. ComponentSize size = ComponentSize.md,
  12. String? error,
  13. FormErrors? errors,
  14. String? helpText,
  15. String? className,
  16. Object? prefix,
  17. Object? suffix,
  18. void onPrefixTap(
    1. Object event
    )?,
  19. void onSuffixTap(
    1. Object event
    )?,
  20. DartStyle? prefixDartStyle,
  21. DartStyle? suffixDartStyle,
  22. bool togglePassword = false,
  23. Object? passwordShowIcon,
  24. Object? passwordHideIcon,
  25. String? validator(
    1. String? value
    )?,
  26. AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction,
  27. Map<String, Object?> props = const {},
  28. Map<String, Object?> inputProps = const {},
  29. Map<String, Object?> style = const {},
  30. Map<String, Object?> labelStyle = const {},
  31. Map<String, Object?> inputStyle = const {},
  32. DartStyle? dartStyle,
  33. DartStyle? labelDartStyle,
  34. DartStyle? inputDartStyle,
  35. void onChanged(
    1. Object event
    )?,
  36. void onBlur(
    1. Object event
    )?,
  37. void onSubmitted(
    1. String value
    )?,
})

Creates a text input field.

Implementation

TextField({
  String? label,
  String? name,
  TextEditingController? controller,
  Object? value,
  String? placeholder,
  String type = 'text',
  bool required = false,
  bool disabled = false,
  bool readonly = false,
  InputVariant variant = InputVariant.outline,
  ComponentSize size = ComponentSize.md,
  String? error,
  FormErrors? errors,
  String? helpText,
  String? className,
  Object? prefix,
  Object? suffix,
  void Function(Object event)? onPrefixTap,
  void Function(Object event)? onSuffixTap,
  DartStyle? prefixDartStyle,
  DartStyle? suffixDartStyle,
  bool togglePassword = false,
  Object? passwordShowIcon,
  Object? passwordHideIcon,
  String? Function(String? value)? validator,
  AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction,
  Map<String, Object?> props = const {},
  Map<String, Object?> inputProps = const {},
  Map<String, Object?> style = const {},
  Map<String, Object?> labelStyle = const {},
  Map<String, Object?> inputStyle = const {},
  DartStyle? dartStyle,
  DartStyle? labelDartStyle,
  DartStyle? inputDartStyle,
  void Function(Object event)? onChanged,
  void Function(Object event)? onBlur,
  void Function(String value)? onSubmitted,
}) : super(
        'div',
        props: fieldWrapperProps(
          props: props,
          className: className,
          dartStyle: dartStyle,
          style: style,
        ),
        children: _children(
          label: label,
          name: name,
          value: controller?.text ?? value,
          placeholder: placeholder,
          type: type,
          required: required,
          disabled: disabled,
          readonly: readonly,
          variant: variant,
          size: size,
          error: resolveFieldError(
            name: name,
            error: error,
            errors: errors,
            validator: validator,
            value: (controller?.text ?? value)?.toString(),
            autovalidateMode: autovalidateMode,
          ),
          helpText: helpText,
          prefix: prefix,
          suffix: suffix,
          onPrefixTap: onPrefixTap,
          onSuffixTap: onSuffixTap,
          prefixDartStyle: prefixDartStyle,
          suffixDartStyle: suffixDartStyle,
          togglePassword: togglePassword,
          passwordShowIcon: passwordShowIcon,
          passwordHideIcon: passwordHideIcon,
          validator: validator,
          autovalidateMode: autovalidateMode,
          inputProps: inputProps,
          labelStyle: labelStyle,
          inputStyle: inputStyle,
          labelDartStyle: labelDartStyle,
          inputDartStyle: inputDartStyle,
          controller: controller,
          onChanged: onChanged,
          onBlur: onBlur,
          onSubmitted: onSubmitted,
        ),
      ) {
  if (controller != null && validator != null) {
    controller.validator ??= validator;
  }
}