ArnaTextFormField constructor
ArnaTextFormField({
- Key? key,
- FormFieldSetter<
String> ? onSaved, - FormFieldValidator<
String> ? validator, - AutovalidateMode? autovalidateMode,
- TextEditingController? controller,
- String? initialValue,
- FocusNode? focusNode,
- String? hintText,
- Widget? prefix,
- ArnaOverlayVisibilityMode prefixMode = ArnaOverlayVisibilityMode.always,
- Widget? suffix,
- ArnaOverlayVisibilityMode suffixMode = ArnaOverlayVisibilityMode.always,
- ArnaOverlayVisibilityMode clearButtonMode = ArnaOverlayVisibilityMode.never,
- TextInputType? keyboardType,
- TextInputAction? textInputAction,
- TextCapitalization textCapitalization = TextCapitalization.none,
- StrutStyle? strutStyle,
- TextAlign textAlign = TextAlign.start,
- TextAlignVertical? textAlignVertical,
- TextDirection? textDirection,
- bool readOnly = false,
- ToolbarOptions? toolbarOptions,
- bool? showCursor,
- bool autofocus = false,
- String obscuringCharacter = '•',
- bool obscureText = false,
- bool autocorrect = true,
- SmartDashesType? smartDashesType,
- SmartQuotesType? smartQuotesType,
- bool enableSuggestions = true,
- int? maxLines = 1,
- int? minLines,
- bool expands = false,
- int? maxLength,
- MaxLengthEnforcement? maxLengthEnforcement,
- ValueChanged<
String> ? onChanged, - VoidCallback? onEditingComplete,
- ValueChanged<
String> ? onFieldSubmitted, - List<
TextInputFormatter> ? inputFormatters, - bool? enabled,
- double cursorWidth = Styles.cursorWidth,
- double? cursorHeight,
- Radius? cursorRadius = const Radius.circular(Styles.cursorRadius),
- Color? accentColor,
- Brightness? keyboardAppearance,
- EdgeInsets scrollPadding = const EdgeInsets.all(Styles.padding),
- bool? enableInteractiveSelection,
- TextSelectionControls? selectionControls,
- GestureTapCallback? onTap,
- MouseCursor cursor = MouseCursor.defer,
- ScrollController? scrollController,
- ScrollPhysics? scrollPhysics,
- Iterable<
String> ? autofillHints, - String? restorationId,
- bool enableIMEPersonalizedLearning = true,
Creates a FormField that contains an ArnaTextField.
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 ArnaTextField class.
Implementation
ArnaTextFormField({
super.key,
super.onSaved,
super.validator,
AutovalidateMode? autovalidateMode,
this.controller,
String? initialValue,
FocusNode? focusNode,
String? hintText,
Widget? prefix,
ArnaOverlayVisibilityMode prefixMode = ArnaOverlayVisibilityMode.always,
Widget? suffix,
ArnaOverlayVisibilityMode suffixMode = ArnaOverlayVisibilityMode.always,
ArnaOverlayVisibilityMode clearButtonMode = ArnaOverlayVisibilityMode.never,
TextInputType? keyboardType,
TextInputAction? textInputAction,
TextCapitalization textCapitalization = TextCapitalization.none,
StrutStyle? strutStyle,
TextAlign textAlign = TextAlign.start,
TextAlignVertical? textAlignVertical,
TextDirection? textDirection,
bool readOnly = false,
ToolbarOptions? toolbarOptions,
bool? showCursor,
bool autofocus = false,
String obscuringCharacter = '•',
bool obscureText = false,
bool autocorrect = true,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
bool enableSuggestions = true,
int? maxLines = 1,
int? minLines,
bool expands = false,
int? maxLength,
MaxLengthEnforcement? maxLengthEnforcement,
ValueChanged<String>? onChanged,
VoidCallback? onEditingComplete,
ValueChanged<String>? onFieldSubmitted,
List<TextInputFormatter>? inputFormatters,
bool? enabled,
double cursorWidth = Styles.cursorWidth,
double? cursorHeight,
Radius? cursorRadius = const Radius.circular(Styles.cursorRadius),
Color? accentColor,
Brightness? keyboardAppearance,
EdgeInsets scrollPadding = const EdgeInsets.all(Styles.padding),
bool? enableInteractiveSelection,
TextSelectionControls? selectionControls,
GestureTapCallback? onTap,
MouseCursor cursor = MouseCursor.defer,
ScrollController? scrollController,
ScrollPhysics? scrollPhysics,
Iterable<String>? autofillHints,
super.restorationId,
bool enableIMEPersonalizedLearning = true,
}) : assert(initialValue == null || controller == null),
assert(obscuringCharacter.length == 1),
assert(maxLines == null || maxLines > 0),
assert(minLines == null || minLines > 0),
assert(
(maxLines == null) || (minLines == null) || (maxLines >= minLines),
"minLines can't be greater than maxLines",
),
assert(
!expands || (maxLines == null && minLines == null),
'minLines and maxLines must be null when expands is true.',
),
assert(
!obscureText || maxLines == 1,
'Obscured fields cannot be multiline.',
),
assert(maxLength == null || maxLength > 0),
super(
initialValue:
controller != null ? controller.text : (initialValue ?? ''),
enabled: enabled ?? true,
autovalidateMode: autovalidateMode ?? AutovalidateMode.disabled,
builder: (FormFieldState<String> field) {
final _ArnaTextFormFieldState state =
field as _ArnaTextFormFieldState;
void onChangedHandler(String value) {
field.didChange(value);
if (onChanged != null) {
onChanged(value);
}
}
return UnmanagedRestorationScope(
bucket: field.bucket,
child: ArnaTextField(
controller: state._effectiveController,
focusNode: focusNode,
hintText: hintText,
prefix: prefix,
prefixMode: prefixMode,
suffix: suffix,
suffixMode: suffixMode,
clearButtonMode: clearButtonMode,
keyboardType: keyboardType,
textInputAction: textInputAction,
textCapitalization: textCapitalization,
strutStyle: strutStyle,
textAlign: textAlign,
textAlignVertical: textAlignVertical,
textDirection: textDirection,
readOnly: readOnly,
toolbarOptions: toolbarOptions,
showCursor: showCursor,
autofocus: autofocus,
obscuringCharacter: obscuringCharacter,
obscureText: obscureText,
autocorrect: autocorrect,
smartDashesType: smartDashesType ??
(obscureText
? SmartDashesType.disabled
: SmartDashesType.enabled),
smartQuotesType: smartQuotesType ??
(obscureText
? SmartQuotesType.disabled
: SmartQuotesType.enabled),
enableSuggestions: enableSuggestions,
maxLines: maxLines,
minLines: minLines,
expands: expands,
maxLength: maxLength,
maxLengthEnforcement: maxLengthEnforcement,
onChanged: onChangedHandler,
onEditingComplete: onEditingComplete,
onSubmitted: onFieldSubmitted,
inputFormatters: inputFormatters,
enabled: enabled ?? true,
cursorWidth: cursorWidth,
cursorHeight: cursorHeight,
cursorRadius: cursorRadius,
accentColor: accentColor,
keyboardAppearance: keyboardAppearance,
scrollPadding: scrollPadding,
enableInteractiveSelection:
enableInteractiveSelection ?? (!obscureText || !readOnly),
selectionControls: selectionControls,
onTap: onTap,
cursor: cursor,
scrollController: scrollController,
scrollPhysics: scrollPhysics,
autofillHints: autofillHints,
restorationId: restorationId,
enableIMEPersonalizedLearning: enableIMEPersonalizedLearning,
),
);
},
);