FloatingSearchBar class

An expandable material floating search bar with customizable transitions similar to the ones used extensively by Google in their apps.

Inheritance

Constructors

FloatingSearchBar({Key? key, Duration implicitDuration = const Duration(milliseconds: 600), Curve implicitCurve = Curves.linear, Widget? body, Color? accentColor, Color? backgroundColor, Color? shadowColor = Colors.black87, Color? iconColor, Color? backdropColor, EdgeInsetsGeometry? margins, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? insets, double height = 48.0, double elevation = 4.0, double? width, double? openWidth, double? axisAlignment = 0.0, double? openAxisAlignment, BorderSide? border, BorderRadius? borderRadius = const BorderRadius.all(Radius.circular(4)), TextStyle? hintStyle, TextStyle? queryStyle, bool clearQueryOnClose = true, bool automaticallyImplyDrawerHamburger = true, bool automaticallyImplyBackButton = true, bool closeOnBackdropTap = true, dynamic progress = false, Duration transitionDuration = const Duration(milliseconds: 500), Curve transitionCurve = Curves.ease, Duration debounceDelay = Duration.zero, Widget? title, String? hint = 'Search...', List<Widget>? actions, List<Widget>? leadingActions, OnQueryChangedCallback? onQueryChanged, OnQueryChangedCallback? onSubmitted, OnFocusChangedCallback? onFocusChanged, FloatingSearchBarTransition? transition, required FloatingSearchBarBuilder builder, FloatingSearchBarController? controller, TextInputAction textInputAction = TextInputAction.search, TextInputType textInputType = TextInputType.text, bool autocorrect = true, ToolbarOptions? toolbarOptions, Duration? showAfter, bool isScrollControlled = false, ScrollPhysics? physics, ScrollController? scrollController, EdgeInsets scrollPadding = const EdgeInsets.symmetric(vertical: 16), bool showCursor = true, bool initiallyHidden = false, ValueChanged<KeyEvent>? onKeyEvent})
const

Properties

accentColor Color?
The color used for elements such as the progress indicator.
final
actions List<Widget>?
A list of widgets displayed in a row after the TextField.
final
autocorrect bool
Enable or disable autocorrection of the TextField of this FloatingSearchBar.
final
automaticallyImplyBackButton bool
Whether to automatically display a back button if the enclosing route can be popped.
final
automaticallyImplyDrawerHamburger bool
Whether a hamburger menu should be shown when there is a Scaffold with a Drawer in the widget tree.
final
axisAlignment double?
How the FloatingSearchBar should be aligned when the available width is bigger than the width specified by width.
final
backdropColor Color?
The color that fills the available space when the FloatingSearchBar is opened.
final
backgroundColor Color?
The color of the card.
final
body Widget?
The widget displayed below the FloatingSearchBar.
final
border BorderSide?
The border of the card.
final
borderRadius BorderRadius?
The BorderRadius of the card.
final
builder FloatingSearchBarBuilder
The builder for the body of this FloatingSearchBar.
final
clearQueryOnClose bool
Whether the current query should be cleared when the FloatingSearchBar was closed.
final
closeOnBackdropTap bool
Whether the FloatingSearchBar should be closed when the backdrop was tapped.
final
controller FloatingSearchBarController?
The controller for this FloatingSearchBar which can be used to programatically open, close, show or hide the FloatingSearchBar.
final
curve Curve
finalinherited
debounceDelay Duration
The delay between the time the user stopped typing and the invocation of the onQueryChanged callback.
final
duration Duration
finalinherited
elevation double
The elevation of the card.
final
hashCode int
The hash code for this object.
no setterinherited
height double
The height of the card.
final
hint String?
The text value of the hint of the TextField.
final
hintStyle TextStyle?
The TextStyle for the hint in the TextField.
final
iconColor Color?
When specified, overrides the themes icon color for this FloatingSearchBar, for example to easily adjust the icon color for all actions and leadingActions.
final
insets EdgeInsetsGeometry?
The padding between leadingActions, the input field and actions, respectively.
final
isScrollControlled bool
Whether the builder of this FloatingSearchBar is using its own Scrollable.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
leadingActions List<Widget>?
A list of widgets displayed in a row before the TextField.
final
margins EdgeInsetsGeometry?
The insets from the edges of its parent.
final
onFocusChanged OnFocusChangedCallback?
A callback that gets invoked when the FloatingSearchBar receives or looses focus.
final
onKeyEvent ValueChanged<KeyEvent>?
Allow processing any keypress into the input text.
final
onQueryChanged OnQueryChangedCallback?
A callback that gets invoked when the input of the query inside the TextField changed.
final
onSubmitted OnQueryChangedCallback?
A callback that gets invoked when the user submitted their query (e.g. hit the search button).
final
openAxisAlignment double?
How the FloatingSearchBar should be aligned when the available width is bigger than the width specified by openWidth.
final
openWidth double?
The max width of the FloatingSearchBar when opened.
final
padding EdgeInsetsGeometry?
The padding of the card.
final
physics ScrollPhysics?
The ScrollPhysics of the SingleChildScrollView for the body of this FloatingSearchBar.
final
progress → dynamic
The progress of the LinearProgressIndicator inside the bar.
final
queryStyle TextStyle?
The TextStyle for the input of the TextField.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollController ScrollController?
The ScrollController of the SingleChildScrollView for the body of this FloatingSearchBar.
final
scrollPadding EdgeInsets
The EdgeInsets of the SingleChildScrollView holding the expandable body of this FloatingSearchBar.
final
shadowColor Color?
The color of the shadow drawn when elevation > 0.
final
showAfter Duration?
Hides the FloatingSearchBar intially for the specified duration and then translates it from the top to its position.
final
showCursor bool
To show the cursor in the textfield or not
final
textInputAction TextInputAction
The TextInputAction to be used by the TextField of this FloatingSearchBar.
final
textInputType TextInputType
The TextInputType of the TextField of this FloatingSearchBar.
final
title Widget?
A widget that is shown in place of the TextField when the FloatingSearchBar is closed.
final
toolbarOptions ToolbarOptions?
The ToolbarOptions of the TextField of this FloatingSearchBar.
final
transition FloatingSearchBarTransition?
The transition to be used for animating between closed and opened state.
final
transitionCurve Curve
The curve for the animation between opened and closed state.
final
transitionDuration Duration
The duration of the animation between opened and closed state.
final
width double?
The max width of the FloatingSearchBar.
final

Methods

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

Static Methods

of(BuildContext context) FloatingSearchBarState?