SearchScreen class

A full-screen search interface.

This widget provides a complete search experience on a dedicated screen, as an alternative to using SearchDelegate. It's useful when you want more control over the search UI or want to integrate search with go_router.

Performance features:

  • Debounced search (300ms) to reduce unnecessary queries
  • Minimal rebuilds using ValueNotifier for clear button visibility
  • Automatic search-as-you-type (configurable via searchOnChange)
Inheritance

Constructors

SearchScreen.new({String? initialQuery, Widget customResultBuilder(BuildContext, WidgetRef)?, bool searchOnChange = true, Duration debounceDuration = const Duration(milliseconds: 300), Key? key})
Creates a search screen.
const

Properties

customResultBuilder Widget Function(BuildContext, WidgetRef)?
Custom builder for search results.
final
debounceDuration Duration
The debounce duration for search-as-you-type. Only applies when searchOnChange is true. Defaults to 300ms.
final
hashCode int
The hash code for this object.
no setterinherited
initialQuery String?
Initial query to pre-fill in the search field.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
searchOnChange bool
Whether to search automatically as the user types. If false, search only occurs when user presses enter or search button. Defaults to true.
final

Methods

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