GlassTextField class Panels and controls
A single line of text in a glass capsule.
An EditableText in a capsule kGlassFieldHeight tall, with an optional leading and trailing widget and a placeholder while it is empty. The text is 17 px in the label colour that reads over the glass (GlassThemeData.legibility), the placeholder at 0.3 of it and the icons at 0.6. A tap anywhere on the capsule focuses the field.
Glass is for the search field a bar carries: most of iOS 26's fields are not glass, and a field on a glass card is better an ordinary one.
GlassBar(
padding: const EdgeInsets.all(4),
child: GlassTextField.search(
controller: query,
onSubmitted: (String text) => runSearch(text),
),
)
Note: the blinking caret and the typed text are inside the surface's own subtree, so neither is a capture: a focused field over a still screen records nothing.
See also:
- GlassTextField.search, the bar's search field.
- GlassBar, which usually carries it.
- Text field on the site.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- GlassTextField
Constructors
-
GlassTextField({TextEditingController? controller, FocusNode? focusNode, String? placeholder, Widget? leading, Widget? trailing, ValueChanged<
String> ? onChanged, ValueChanged<String> ? onSubmitted, TextInputType? keyboardType, TextInputAction? textInputAction, bool autofocus = false, bool obscureText = false, GlassFinish? finish, Color? cursorColor, Key? key}) -
A field with nothing ahead of the text and no placeholder unless given.
const
-
GlassTextField.search({TextEditingController? controller, FocusNode? focusNode, String? placeholder = 'Search', Widget? leading = const _Magnifier(), Widget? trailing, ValueChanged<
String> ? onChanged, ValueChanged<String> ? onSubmitted, bool autofocus = false, GlassFinish? finish, Color? cursorColor, Key? key}) -
The search field of a bar: a magnifier ahead of the text, "Search" when
empty, and the keyboard's search action.
const
Properties
- autofocus → bool
-
Whether the field takes the focus as soon as it is built.
final
- controller → TextEditingController?
-
The text being edited. Null makes one the field owns and disposes.
final
- cursorColor → Color?
-
The caret, and the selection at 0.3 of it. Null for iOS's
systemBluein the appearance of the field's own label.final - finish → GlassFinish?
-
The optics. Null takes the theme's.
final
- focusNode → FocusNode?
-
The field's focus. Null makes one the field owns and disposes.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardType → TextInputType?
-
Which keyboard to ask for. Null leaves it to EditableText.
final
- leading → Widget?
-
Ahead of the text and after it — an icon, a clear button.
final
- obscureText → bool
-
Whether the text is hidden, as a password's is.
final
-
onChanged
→ ValueChanged<
String> ? -
Called with the whole text on every edit.
final
-
onSubmitted
→ ValueChanged<
String> ? -
Called with the whole text when the keyboard's action is pressed.
final
- placeholder → String?
-
Shown, dimmed, while the field is empty.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- textInputAction → TextInputAction?
-
The keyboard's action button. GlassTextField.search asks for
TextInputAction.search.
final
- trailing → Widget?
-
After the text — a clear button, a microphone. See leading.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< GlassTextField> -
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.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent 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, int wrapWidth = 65}) → 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.
inherited