NxSearchTextField class

A Material 3 search field widget with support for different visual states and custom styling.

This widget wraps Flutter's SearchBar widget and provides additional customization options for appearance and behavior. It includes a search icon by default and supports trailing widgets for additional actions.

The widget's appearance can be customized for different states (enabled, disabled, focused, hovered) using WidgetStateProperty parameters.

Example usage:

NxSearchTextField(
  onChanged: (value) {
    // Handle search text changes
  },
  onSubmitted: (value) {
    // Handle search submission
  },
  hintText: 'Search items...',
  fillColor: const WidgetStatePropertyAll<Color>(Colors.grey),
  trailing: [
    IconButton(
      icon: Icon(Icons.clear),
      onPressed: () {
        // Clear search
      },
    ),
  ],
)
Inheritance

Constructors

NxSearchTextField.new({Key? key, dynamic onChanged(String)?, dynamic onSubmitted(String)?, dynamic onTap()?, WidgetStateProperty<Color?>? fillColor, WidgetStateProperty<TextStyle?>? textStyle, WidgetStateProperty<TextStyle?>? hintStyle, String? hintText, TextEditingController? controller, FocusNode? focusNode, double? width, double? height, WidgetStatePropertyAll<double>? elevation, Iterable<Widget>? trailing, WidgetStateProperty<BorderSide?>? side, WidgetStateProperty<OutlinedBorder?>? shape})
Creates a search text field.
const

Properties

controller TextEditingController?
A controller for the text being edited.
final
elevation WidgetStatePropertyAll<double>?
The elevation of the search field for all states.
final
fillColor WidgetStateProperty<Color?>?
The background color of the search field for different states.
final
focusNode FocusNode?
Defines the keyboard focus for this widget.
final
hashCode int
The hash code for this object.
no setterinherited
height double?
The height of the search field.
final
hintStyle WidgetStateProperty<TextStyle?>?
The text style for the hint text in different states.
final
hintText String?
The placeholder text shown when the field is empty.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onChanged → dynamic Function(String)?
Called when the user changes the text in the field.
final
onSubmitted → dynamic Function(String)?
Called when the user submits the search (e.g., by pressing enter).
final
onTap → dynamic Function()?
Called when the user taps on the search field.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shape WidgetStateProperty<OutlinedBorder?>?
The shape of the search field for different states.
final
side WidgetStateProperty<BorderSide?>?
The border style for different states.
final
textStyle WidgetStateProperty<TextStyle?>?
The text style for the input text in different states.
final
trailing Iterable<Widget>?
Additional widgets to display after the search icon.
final
width double?
The width of the search field.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<NxSearchTextField>
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