TextFieldBlocBuilder constructor
- Key? key,
- required TextFieldBloc textFieldBloc,
- bool enableOnlyWhenFormBlocCanSubmit = false,
- bool isEnabled = true,
- FieldBlocErrorBuilder? errorBuilder,
- SuffixButton? suffixButton,
- EdgeInsetsGeometry? padding,
- bool removeSuggestionOnLongPress = false,
- FocusNode? focusNode,
- InputDecoration decoration = const InputDecoration(),
- TextInputType? keyboardType,
- TextInputAction? textInputAction,
- TextCapitalization textCapitalization = TextCapitalization.none,
- @Deprecated('Use textStyle') TextStyle? style,
- TextStyle? textStyle,
- MaterialStateProperty<
Color?> ? textColor, - StrutStyle? strutStyle,
- bool? obscureText,
- TextAlign? textAlign,
- TextAlignVertical? textAlignVertical,
- TextDirection? textDirection,
- bool? showCursor,
- bool autofocus = false,
- bool autocorrect = true,
- int? maxLines = 1,
- int? minLines,
- bool expands = false,
- int? maxLength,
- MaxLengthEnforcement maxLengthEnforced = MaxLengthEnforcement.enforced,
- ValueChanged<
String> ? onChanged, - VoidCallback? onEditingComplete,
- ValueChanged<
String> ? onSubmitted, - List<
TextInputFormatter> ? inputFormatters, - double cursorWidth = 2.0,
- Radius? cursorRadius,
- Color? cursorColor,
- Brightness? keyboardAppearance,
- EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- bool enableInteractiveSelection = true,
- GestureTapCallback? onTap,
- InputCounterWidgetBuilder? buildCounter,
- ScrollController? scrollController,
- ScrollPhysics? scrollPhysics,
- SuggestionsBoxDecoration? suggestionsBoxDecoration,
- TextStyle? suggestionTextStyle,
- Duration debounceSuggestionDuration = const Duration(milliseconds: 300),
- bool getImmediateSuggestions = true,
- Duration suggestionsAnimationDuration = const Duration(milliseconds: 700),
- FocusNode? nextFocusNode,
- bool hideOnLoadingSuggestions = false,
- bool hideOnEmptySuggestions = false,
- bool hideOnSuggestionsError = false,
- WidgetBuilder? loadingSuggestionsBuilder,
- WidgetBuilder? suggestionsNotFoundBuilder,
- ErrorBuilder? suggestionsErrorBuilder,
- bool keepSuggestionsOnLoading = false,
- bool showSuggestionsWhenIsEmpty = true,
- bool readOnly = false,
- ToolbarOptions? toolbarOptions,
- bool enableSuggestions = true,
- bool animateWhenCanShow = true,
- Widget? obscureTextTrueIcon,
- Widget? obscureTextFalseIcon,
- Widget? clearTextIcon,
- Iterable<
String> ? autofillHints, - Widget asyncValidatingIcon = const SizedBox(height: 24, width: 24, child: Padding(padding: EdgeInsets.all(8.0), child: CircularProgressIndicator(strokeWidth: 2.0))),
Creates a Material Design text field
If decoration
is non-null (which is the default), the text field requires
one of its ancestors to be a Material widget.
To remove the decoration entirely (including the extra padding introduced
by the decoration to save space for the labels), set the decoration
to
null.
The maxLines
property can be set to null to remove the restriction on
the number of lines. By default, it is one, meaning this is a single-line
text field. maxLines
must not be zero.
The maxLength
property is set to null by default, which means the
number of characters allowed in the text field is not restricted. If
maxLength
is set a character counter will be displayed below the
field showing how many characters have been entered. If the value is
set to a positive integer it will also display the maximum allowed
number of characters to be entered. If the value is set to
TextFieldBlocBuilder.noMaxLength then only the current length is displayed.
After maxLength
characters have been input, additional input
is ignored, unless maxLengthEnforced
is set to false. The text field
enforces the length with a LengthLimitingTextInputFormatter, which is
evaluated after the supplied inputFormatters
, if any. The maxLength
value must be either null or greater than zero.
If maxLengthEnforced
is set to false, then more than maxLength
characters may be entered, and the error counter and divider will
switch to the decoration.errorStyle
when the limit is exceeded.
The text cursor is not shown if showCursor
is false or if showCursor
is null (the default) and readOnly
is true.
The textAlign
, autofocus
, obscureText
, readOnly
, autocorrect
,
maxLengthEnforced
, scrollPadding
, maxLines
, and maxLength
arguments must not be null.
See also:
maxLength
, which discusses the precise meaning of "number of characters" and how it may differ from the intuitive meaning.
Implementation
const TextFieldBlocBuilder({
Key? key,
required this.textFieldBloc,
this.enableOnlyWhenFormBlocCanSubmit = false,
this.isEnabled = true,
this.errorBuilder,
this.suffixButton,
this.padding,
this.removeSuggestionOnLongPress = false,
this.focusNode,
this.decoration = const InputDecoration(),
TextInputType? keyboardType,
this.textInputAction,
this.textCapitalization = TextCapitalization.none,
@Deprecated('Use textStyle') TextStyle? style,
TextStyle? textStyle,
this.textColor,
this.strutStyle,
this.obscureText,
this.textAlign,
this.textAlignVertical,
this.textDirection,
this.showCursor,
this.autofocus = false,
this.autocorrect = true,
this.maxLines = 1,
this.minLines,
this.expands = false,
this.maxLength,
this.maxLengthEnforced = MaxLengthEnforcement.enforced,
this.onChanged,
this.onEditingComplete,
this.onSubmitted,
this.inputFormatters,
this.cursorWidth = 2.0,
this.cursorRadius,
this.cursorColor,
this.keyboardAppearance,
this.scrollPadding = const EdgeInsets.all(20.0),
this.dragStartBehavior = DragStartBehavior.start,
this.enableInteractiveSelection = true,
this.onTap,
this.buildCounter,
this.scrollController,
this.scrollPhysics,
this.suggestionsBoxDecoration,
this.suggestionTextStyle,
this.debounceSuggestionDuration = const Duration(milliseconds: 300),
this.getImmediateSuggestions = true,
this.suggestionsAnimationDuration = const Duration(milliseconds: 700),
this.nextFocusNode,
this.hideOnLoadingSuggestions = false,
this.hideOnEmptySuggestions = false,
this.hideOnSuggestionsError = false,
this.loadingSuggestionsBuilder,
this.suggestionsNotFoundBuilder,
this.suggestionsErrorBuilder,
this.keepSuggestionsOnLoading = false,
this.showSuggestionsWhenIsEmpty = true,
this.readOnly = false,
this.toolbarOptions,
this.enableSuggestions = true,
this.animateWhenCanShow = true,
this.obscureTextTrueIcon,
this.obscureTextFalseIcon,
this.clearTextIcon,
this.autofillHints,
this.asyncValidatingIcon = const SizedBox(
height: 24,
width: 24,
child: Padding(
padding: EdgeInsets.all(8.0),
child: CircularProgressIndicator(
strokeWidth: 2.0,
),
),
),
}) : 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 || (minLines == null),
'minLines and maxLines must be null when expands is true.',
),
assert(maxLength == null ||
maxLength == TextFieldBlocBuilder.noMaxLength ||
maxLength > 0),
keyboardType = keyboardType ??
(maxLines == 1 ? TextInputType.text : TextInputType.multiline),
textStyle = textStyle ?? style,
super(key: key);