AppBarAutoHide class
A widget that automatically hides and shows the AppBar based on scroll events.
This widget wraps an AppBar and listens to scroll notifications to determine whether the AppBar should be visible or hidden. It animates the transition between these states using a fade and size transition.
To use this widget, provide a ValueNotifier that emits scroll notifications from a scrollable widget, such as a ListView or ScrollView. The AppBarAutoHide widget will listen to this notifier and update its state accordingly.
You can customize the behavior of the widget using the following properties:
isAutoHide
: Whether the AppBar should automatically hide and show.autoHideThreshold
: The scroll threshold at which the AppBar should start hiding.animationDuration
: The duration of the hide/show animation.leading
,title
,actions
,flexibleSpace
,bottom
,elevation
,scrolledUnderElevation
,notificationPredicate
,shadowColor
,surfaceTintColor
,shape
,backgroundColor
,foregroundColor
,iconTheme
,actionsIconTheme
,primary
,centerTitle
,excludeHeaderSemantics
,titleSpacing
,toolbarOpacity
,bottomOpacity
,toolbarHeight
,leadingWidth
,toolbarTextStyle
,titleTextStyle
,systemOverlayStyle
,forceMaterialTransparency
: These properties are passed directly to the underlying AppBar widget.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- AppBarAutoHide
- Implemented types
Constructors
-
AppBarAutoHide.new({Key? key, required ValueNotifier<
ScrollNotification?> notifier, bool isAutoHide = true, double autoHideThreshold = 200.0, Widget? leading, bool automaticallyImplyLeading = false, Duration animationDuration = const Duration(milliseconds: 300), Widget? title, List<Widget> ? actions, Widget? flexibleSpace, PreferredSizeWidget? bottom, double? elevation, double? scrolledUnderElevation, ScrollNotificationPredicate? notificationPredicate, Color? shadowColor, Color? surfaceTintColor, ShapeBorder? shape, Color? backgroundColor, Color? foregroundColor, IconThemeData? iconTheme, IconThemeData? actionsIconTheme, bool primary = true, bool? centerTitle, bool excludeHeaderSemantics = false, double? titleSpacing, double toolbarOpacity = 1.0, double bottomOpacity = 1.0, double? toolbarHeight, double? leadingWidth, TextStyle? toolbarTextStyle, TextStyle? titleTextStyle, SystemUiOverlayStyle? systemOverlayStyle, bool forceMaterialTransparency = false}) -
Creates an AppBarAutoHide widget.
const
Properties
-
actions
→ List<
Widget> ? -
A list of Widgets to display in a row after the title widget.
final
- actionsIconTheme → IconThemeData?
-
The values for the app bar's actions' theme.
final
- animationDuration → Duration
-
The duration of the hide/show animation.
final
- autoHideThreshold → double
-
The scroll threshold at which the AppBar should start hiding.
final
- automaticallyImplyLeading → bool
-
Controls whether we should try to imply the leading widget if null.
final
- backgroundColor → Color?
-
The color to use for the app bar's background.
final
- bottom → PreferredSizeWidget?
-
This widget appears across the bottom of the app bar.
final
- bottomOpacity → double
-
How opaque the bottom part of the app bar is.
final
- centerTitle → bool?
-
Whether the title should be centered.
final
- elevation → double?
-
The z-coordinate at which to place this app bar relative to its parent.
final
- excludeHeaderSemantics → bool
-
Whether the title should be wrapped with header Semantics.
final
- flexibleSpace → Widget?
-
This widget is stacked behind the toolbar and the tab bar.
final
- forceMaterialTransparency → bool
-
Force the AppBar to be Material regardless the theme.
final
- foregroundColor → Color?
-
The default color for Text and Icons within the app bar.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- iconTheme → IconThemeData?
-
The values for the app bar's theme.
final
- isAutoHide → bool
-
Whether the AppBar should automatically hide and show.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- leading → Widget?
-
A widget to display before the title.
final
- leadingWidth → double?
-
Defines the width of leading widget.
final
- notificationPredicate → ScrollNotificationPredicate?
-
A check that specifies which kind of scroll notifications should be
handled by this widget.
final
-
notifier
→ ValueNotifier<
ScrollNotification?> -
The ValueNotifier that emits scroll notifications.
final
- preferredSize → Size
-
The size this widget would prefer if it were otherwise unconstrained.
no setteroverride
- primary → bool
-
Whether this app bar is being displayed at the top of the screen.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrolledUnderElevation → double?
-
The elevation that the app bar should have when it is scrolled under.
final
- shadowColor → Color?
-
The color to paint the shadow below the app bar.
final
- shape → ShapeBorder?
-
The shape of the app bar's material.
final
- surfaceTintColor → Color?
-
The color to paint the surface behind the app bar.
final
- systemOverlayStyle → SystemUiOverlayStyle?
-
Specifies the system overlays to be placed over the app bar.
final
- title → Widget?
-
The primary widget displayed in the AppBar.
final
- titleSpacing → double?
-
The spacing around title content on the horizontal axis.
final
- titleTextStyle → TextStyle?
-
TextStyle for the AppBar's title widget.
final
- toolbarHeight → double?
-
A size whose height defines the height of the toolbar.
final
- toolbarOpacity → double
-
How opaque the toolbar part of the app bar is.
final
- toolbarTextStyle → TextStyle?
-
Default text style for the AppBar's TextSpans.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _AppBarAutoHideState -
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