GlassTextField class
A glass text field widget following Apple's input field design.
GlassTextField provides a text input field with glass morphism effect, matching iOS design patterns with customizable styling.
Usage Modes
Grouped Mode (default)
AdaptiveLiquidGlassLayer(
settings: LiquidGlassSettings(...),
child: Column(
children: [
GlassTextField(
placeholder: 'Email',
keyboardType: TextInputType.emailAddress,
),
GlassTextField(
placeholder: 'Password',
obscureText: true,
),
],
),
)
Standalone Mode
GlassTextField(
useOwnLayer: true,
settings: LiquidGlassSettings(...),
placeholder: 'Search...',
prefixIcon: Icon(Icons.search, size: 20, color: Colors.white70),
)
Customization Examples
With prefix and suffix icons:
GlassTextField(
placeholder: 'Search',
prefixIcon: Icon(Icons.search, size: 20, color: Colors.white70),
suffixIcon: Icon(Icons.clear, size: 20, color: Colors.white70),
onSuffixTap: () => controller.clear(),
)
Multiline text area:
GlassTextField(
placeholder: 'Enter your message...',
maxLines: 5,
minLines: 3,
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- GlassTextField
Constructors
-
GlassTextField({Key? key, TextEditingController? controller, FocusNode? focusNode, String? placeholder, Widget? prefixIcon, Widget? suffixIcon, VoidCallback? onSuffixTap, bool obscureText = false, TextInputType? keyboardType, TextInputAction? textInputAction, int maxLines = 1, int? minLines, int? maxLength, bool enabled = true, bool readOnly = false, bool autofocus = false, ValueChanged<
String> ? onChanged, ValueChanged<String> ? onSubmitted, List<TextInputFormatter> ? inputFormatters, TextStyle? textStyle, TextStyle? placeholderStyle, EdgeInsetsGeometry padding = const EdgeInsets.symmetric(horizontal: 16, vertical: 12), double iconSpacing = 12.0, LiquidShape shape = const LiquidRoundedSuperellipse(borderRadius: 10), LiquidGlassSettings? settings, bool useOwnLayer = false, GlassQuality quality = GlassQuality.standard}) -
Creates a glass text field.
const
Properties
- autofocus → bool
-
Whether the text field should auto-focus.
final
- controller → TextEditingController?
-
Controls the text being edited.
final
- enabled → bool
-
Whether the text field is enabled.
final
- focusNode → FocusNode?
-
Controls the focus state of the text field.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- iconSpacing → double
-
Spacing between the icons and the text field.
final
-
inputFormatters
→ List<
TextInputFormatter> ? -
Input formatters for the text field.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardType → TextInputType?
-
The type of keyboard to display.
final
- maxLength → int?
-
Maximum number of characters allowed.
final
- maxLines → int
-
Maximum number of lines for the text field.
final
- minLines → int?
-
Minimum number of lines for the text field.
final
- obscureText → bool
-
Whether to obscure the text (for passwords).
final
-
onChanged
→ ValueChanged<
String> ? -
Called when the text changes.
final
-
onSubmitted
→ ValueChanged<
String> ? -
Called when the user submits the text.
final
- onSuffixTap → VoidCallback?
-
Callback when suffix icon is tapped.
final
- padding → EdgeInsetsGeometry
-
Padding inside the text field.
final
- placeholder → String?
-
Placeholder text shown when the field is empty.
final
- placeholderStyle → TextStyle?
-
The style of the placeholder text.
final
- prefixIcon → Widget?
-
Widget displayed at the start of the field.
final
- quality → GlassQuality
-
Rendering quality for the glass effect.
final
- readOnly → bool
-
Whether the text field is read-only.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- settings → LiquidGlassSettings?
-
Glass effect settings (only used when useOwnLayer is true).
final
- shape → LiquidShape
-
Shape of the text field.
final
- suffixIcon → Widget?
-
Widget displayed at the end of the field.
final
- textInputAction → TextInputAction?
-
The action button on the keyboard.
final
- textStyle → TextStyle?
-
The style of the text being edited.
final
- useOwnLayer → bool
-
Whether to create its own layer or use grouped glass.
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