CupertinoSearchTextField class Null safety
A CupertinoTextField that mimics the look and behavior of UIKit's
UISearchTextField
.
This control defaults to showing the basic parts of a UISearchTextField
,
like the 'Search' placeholder, prefix-ed Search icon, and suffix-ed
X-Mark icon.
To control the text that is displayed in the text field, use the controller. For example, to set the initial value of the text field, use a controller that already contains some text such as:
This examples shows how to provide initial text to a CupertinoSearchTextField
using the controller property.
To create a local project with this code sample, run:
flutter create --sample=cupertino.CupertinoSearchTextField.1 mysample
flutter create --sample=cupertino.CupertinoSearchTextField.1 mysample
It is recommended to pass a ValueChanged<String> to both onChanged and onSubmitted parameters in order to be notified once the value of the field changes or is submitted by the keyboard:
This examples shows how to be notified of field changes or submitted text from
a CupertinoSearchTextField.
To create a local project with this code sample, run:
flutter create --sample=cupertino.CupertinoSearchTextField.2 mysample
flutter create --sample=cupertino.CupertinoSearchTextField.2 mysample
See also:
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CupertinoSearchTextField
Constructors
-
CupertinoSearchTextField({Key? key, TextEditingController? controller, ValueChanged<
String> ? onChanged, ValueChanged<String> ? onSubmitted, TextStyle? style, String? placeholder, TextStyle? placeholderStyle, BoxDecoration? decoration, Color? backgroundColor, BorderRadius? borderRadius, EdgeInsetsGeometry padding = const EdgeInsetsDirectional.fromSTEB(3.8, 8, 5, 8), Color itemColor = CupertinoColors.secondaryLabel, double itemSize = 20.0, EdgeInsetsGeometry prefixInsets = const EdgeInsetsDirectional.fromSTEB(6, 0, 0, 4), Widget prefixIcon = const Icon(CupertinoIcons.search), EdgeInsetsGeometry suffixInsets = const EdgeInsetsDirectional.fromSTEB(0, 0, 5, 2), Icon suffixIcon = const Icon(CupertinoIcons.xmark_circle_fill), OverlayVisibilityMode suffixMode = OverlayVisibilityMode.editing, VoidCallback? onSuffixTap, String? restorationId, FocusNode? focusNode, SmartQuotesType? smartQuotesType, SmartDashesType? smartDashesType, bool autofocus = false, VoidCallback? onTap, bool autocorrect = true, bool? enabled}) -
Creates a CupertinoTextField that mimics the look and behavior of
UIKit's
UISearchTextField
.const
Properties
- autocorrect → bool
-
Whether to enable autocorrection.
final
- autofocus → bool
-
Whether this text field should focus itself if nothing else is already
focused.
final
- backgroundColor → Color?
-
Set the decoration property's background color.
final
- borderRadius → BorderRadius?
-
Sets the decoration property's border radius.
final
- controller → TextEditingController?
-
Controls the text being edited.
final
- decoration → BoxDecoration?
-
Sets the decoration for the text field.
final
- enabled → bool?
-
Disables the text field when false.
final
- focusNode → FocusNode?
-
An optional focus node to use as the focus node for this widget.
final
- hashCode → int
- The hash code for this object.
- itemColor → Color
-
Sets the color for the suffix and prefix icons.
final
- itemSize → double
-
Sets the base icon size for the suffix and prefix icons.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onChanged
→ ValueChanged<
String> ? -
Invoked upon user input.
final
-
onSubmitted
→ ValueChanged<
String> ? -
Invoked upon keyboard submission.
final
- onSuffixTap → VoidCallback?
-
Sets the X-Mark (suffix) action.
final
- onTap → VoidCallback?
-
Called for each distinct tap except for every second tap of a double tap.
final
- padding → EdgeInsetsGeometry
-
Sets the padding insets for the text and placeholder.
final
- placeholder → String?
-
A hint placeholder text that appears when the text entry is empty.
final
- placeholderStyle → TextStyle?
-
Sets the style of the placeholder of the text field.
final
- prefixIcon → Widget
-
Sets a prefix widget.
final
- prefixInsets → EdgeInsetsGeometry
-
Sets the padding insets for the suffix.
final
- restorationId → String?
-
Restoration ID to save and restore the state of the text field.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
- smartDashesType → SmartDashesType?
-
Whether to allow the platform to automatically format dashes.
final
- smartQuotesType → SmartQuotesType?
-
Whether to allow the platform to automatically format quotes.
final
- style → TextStyle?
-
Allows changing the style of the text.
final
- suffixIcon → Icon
-
Sets the suffix widget's icon.
final
- suffixInsets → EdgeInsetsGeometry
-
Sets the padding insets for the prefix.
final
- suffixMode → OverlayVisibilityMode
-
Dictates when the X-Mark (suffix) should be visible.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< StatefulWidget> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.protected">@protectedinherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
nonVirtual">@nonVirtualinherited