TextField constructor
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 onPrefixTap(
- Object event
- void onSuffixTap(
- Object event
- DartStyle? prefixDartStyle,
- DartStyle? suffixDartStyle,
- bool togglePassword = false,
- Object? passwordShowIcon,
- Object? passwordHideIcon,
- String? validator(
- String? value
- 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 onChanged(
- Object event
- void onBlur(
- Object event
- void onSubmitted(
- 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;
}
}