EasyTextFormField constructor
EasyTextFormField({
- Key? key,
- required String name,
- TextEditingController? controller,
- String? initialValue,
- FocusNode? focusNode,
- InputDecoration decoration = const InputDecoration(),
- TextInputType? keyboardType,
- TextCapitalization textCapitalization = TextCapitalization.none,
- TextInputAction? textInputAction,
- TextStyle? style,
- StrutStyle? strutStyle,
- TextDirection? textDirection,
- TextAlign textAlign = TextAlign.start,
- TextAlignVertical? textAlignVertical,
- bool autofocus = false,
- bool readOnly = false,
- @Deprecated('Use `contextMenuBuilder` instead.') ToolbarOptions? toolbarOptions,
- bool? showCursor,
- String obscuringCharacter = '•',
- bool obscureText = false,
- bool autocorrect = true,
- SmartDashesType? smartDashesType,
- SmartQuotesType? smartQuotesType,
- bool enableSuggestions = true,
- MaxLengthEnforcement? maxLengthEnforcement,
- int maxLines = 1,
- int? minLines,
- bool expands = false,
- int? maxLength,
- ValueChanged<
String> ? onChanged, - GestureTapCallback? onTap,
- VoidCallback? onEditingComplete,
- ValueChanged<
String> ? onFieldSubmitted, - FormFieldSetter<
String> ? onSaved, - EasyFormFieldValidator<
String?> ? validator, - List<
TextInputFormatter> ? inputFormatters, - bool enabled = true,
- double cursorWidth = 2.0,
- double? cursorHeight,
- Radius? cursorRadius,
- Color? cursorColor,
- Brightness? keyboardAppearance,
- EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
- bool enableInteractiveSelection = true,
- InputCounterWidgetBuilder? buildCounter,
- ScrollPhysics? scrollPhysics,
- Iterable<
String> ? autofillHints, - ContentInsertionConfiguration? contentInsertionConfiguration,
- Clip clipBehavior = Clip.hardEdge,
- String? restorationId,
- bool scribbleEnabled = true,
- bool enableIMEPersonalizedLearning = true,
- EditableTextContextMenuBuilder? contextMenuBuilder,
- bool canRequestFocus = true,
- SpellCheckConfiguration? spellCheckConfiguration,
- TextMagnifierConfiguration? magnifierConfiguration,
- EasyAutovalidateMode autovalidateMode = EasyAutovalidateMode.disabled,
- bool saveOnSubmit = false,
Creates a EasyCustomFormField that contains a TextField.
When a controller
is specified, initialValue
must be null (the
default). If controller
is null, then a TextEditingController
will be constructed automatically and its text
will be initialized
to initialValue
or the empty string.
For documentation about the various parameters, see the TextField class and TextField, the constructor.
Implementation
EasyTextFormField({
Key? key,
required String name,
TextEditingController? controller,
String? initialValue,
FocusNode? focusNode,
InputDecoration decoration = const InputDecoration(),
TextInputType? keyboardType,
TextCapitalization textCapitalization = TextCapitalization.none,
TextInputAction? textInputAction,
TextStyle? style,
StrutStyle? strutStyle,
TextDirection? textDirection,
TextAlign textAlign = TextAlign.start,
TextAlignVertical? textAlignVertical,
bool autofocus = false,
bool readOnly = false,
@Deprecated('Use `contextMenuBuilder` instead.')
ToolbarOptions? toolbarOptions,
bool? showCursor,
String obscuringCharacter = '•',
bool obscureText = false,
bool autocorrect = true,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
bool enableSuggestions = true,
MaxLengthEnforcement? maxLengthEnforcement,
int maxLines = 1,
int? minLines,
bool expands = false,
int? maxLength,
ValueChanged<String>? onChanged,
GestureTapCallback? onTap,
VoidCallback? onEditingComplete,
ValueChanged<String>? onFieldSubmitted,
FormFieldSetter<String>? onSaved,
EasyFormFieldValidator<String?>? validator,
List<TextInputFormatter>? inputFormatters,
bool enabled = true,
double cursorWidth = 2.0,
double? cursorHeight,
Radius? cursorRadius,
Color? cursorColor,
Brightness? keyboardAppearance,
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
bool enableInteractiveSelection = true,
InputCounterWidgetBuilder? buildCounter,
ScrollPhysics? scrollPhysics,
Iterable<String>? autofillHints,
ContentInsertionConfiguration? contentInsertionConfiguration,
Clip clipBehavior = Clip.hardEdge,
String? restorationId,
bool scribbleEnabled = true,
bool enableIMEPersonalizedLearning = true,
EditableTextContextMenuBuilder? contextMenuBuilder,
bool canRequestFocus = true,
SpellCheckConfiguration? spellCheckConfiguration,
TextMagnifierConfiguration? magnifierConfiguration,
EasyAutovalidateMode autovalidateMode = EasyAutovalidateMode.disabled,
bool saveOnSubmit = false,
}) : super(
key: key,
name: name,
controller: controller,
focusNode: focusNode,
initialValue: initialValue ?? '',
controllerBuilder: (value) => TextEditingController(text: value),
controllerRebuilder: (oldController) =>
TextEditingController.fromValue(oldController.value),
valueGet: (controller) => controller.text,
valueSet: (controller, value) => controller.text = value ?? '',
builder: (state, onChangedHandler) {
final InputDecoration effectiveDecoration = decoration
.applyDefaults(Theme.of(state.context).inputDecorationTheme);
return TextField(
controller: state.controller as TextEditingController?,
focusNode: state.focusNode,
decoration:
effectiveDecoration.copyWith(errorText: state.errorText),
keyboardType: keyboardType,
textInputAction: textInputAction,
style: style,
strutStyle: strutStyle,
textAlign: textAlign,
textAlignVertical: textAlignVertical,
textDirection: textDirection,
textCapitalization: textCapitalization,
autofocus: autofocus,
// ignore: deprecated_member_use
toolbarOptions: toolbarOptions,
readOnly: readOnly,
showCursor: showCursor,
obscuringCharacter: obscuringCharacter,
obscureText: obscureText,
autocorrect: autocorrect,
smartDashesType: smartDashesType ??
(obscureText
? SmartDashesType.disabled
: SmartDashesType.enabled),
smartQuotesType: smartQuotesType ??
(obscureText
? SmartQuotesType.disabled
: SmartQuotesType.enabled),
enableSuggestions: enableSuggestions,
maxLengthEnforcement: maxLengthEnforcement,
maxLines: maxLines,
minLines: minLines,
expands: expands,
maxLength: maxLength,
onChanged: onChangedHandler,
onTap: onTap,
onEditingComplete: onEditingComplete,
onSubmitted: (value) {
onFieldSubmitted?.call(value);
if (saveOnSubmit) state.saveForm();
},
inputFormatters: inputFormatters,
enabled: enabled,
cursorWidth: cursorWidth,
cursorHeight: cursorHeight,
cursorRadius: cursorRadius,
cursorColor: cursorColor,
scrollPadding: scrollPadding,
scrollPhysics: scrollPhysics,
keyboardAppearance: keyboardAppearance,
enableInteractiveSelection: enableInteractiveSelection,
buildCounter: buildCounter,
autofillHints: autofillHints,
contentInsertionConfiguration: contentInsertionConfiguration,
clipBehavior: clipBehavior,
restorationId: restorationId,
scribbleEnabled: scribbleEnabled,
enableIMEPersonalizedLearning: enableIMEPersonalizedLearning,
contextMenuBuilder: contextMenuBuilder,
canRequestFocus: canRequestFocus,
spellCheckConfiguration: spellCheckConfiguration,
magnifierConfiguration: magnifierConfiguration,
);
},
onChanged: onChanged,
onSaved: onSaved,
validator: validator,
enabled: enabled,
autovalidateMode: autovalidateMode,
);