SliverNewGradientAppBar class Null safety

A material design app bar that integrates with a CustomScrollView.

An app bar consists of a toolbar and potentially other widgets, such as a TabBar and a FlexibleSpaceBar. App bars typically expose one or more common actions with IconButtons which are optionally followed by a PopupMenuButton for less common operations.

Sliver app bars are typically used as the first child of a CustomScrollView, which lets the app bar integrate with the scroll view so that it can vary in height according to the scroll offset or float above the other content in the scroll view. For a fixed-height app bar at the top of the screen see NewGradientAppBar, which is used in the Scaffold.appBar slot.

The GradientAppBar displays the toolbar widgets, leading, title, and actions, above the bottom (if any). If a flexibleSpace widget is specified then it is stacked behind the toolbar and the bottom widget.

{@tool sample}

This is an example that could be included in a CustomScrollView's CustomScrollView.slivers list:

  expandedHeight: 150.0,
  flexibleSpace: const FlexibleSpaceBar(
    title: Text('Available seats'),
  actions: <Widget>[
      icon: const Icon(Icons.add_circle),
      tooltip: 'Add new entry',
      onPressed: () { /* ... */ },


Animated Examples

The following animations show how app bars with different configurations behave when a user scrolls up and then down again.

The property snap can only be set to true if floating is also true.

See also:



SliverNewGradientAppBar({Key? key, Widget? leading, bool automaticallyImplyLeading = true, Widget? title, List<Widget>? actions, Widget? flexibleSpace, PreferredSizeWidget? bottom, double? elevation, bool forceElevated = false, Gradient? gradient, Brightness? brightness, IconThemeData? iconTheme, IconThemeData? actionsIconTheme, TextTheme? textTheme, bool primary = true, bool? centerTitle, double titleSpacing = NavigationToolbar.kMiddleSpacing, double? expandedHeight, bool floating = false, bool pinned = false, bool snap = false, ShapeBorder? shape})
Creates a material design app bar that can be placed in a CustomScrollView.


actions List<Widget>?
Widgets to display after the title widget.
actionsIconTheme IconThemeData?
The color, opacity, and size to use for trailing app bar icons. This should only be used when the trailing icons should be themed differently than the leading icons.
automaticallyImplyLeading bool
Controls whether we should try to imply the leading widget if null.
bottom PreferredSizeWidget?
This widget appears across the bottom of the appbar.
brightness Brightness?
The brightness of the app bar's material. Typically this is set along with backgroundColor, iconTheme, textTheme.
centerTitle bool?
Whether the title should be centered.
elevation double?
The z-coordinate at which to place this app bar when it is above other content. This controls the size of the shadow below the app bar.
expandedHeight double?
The size of the app bar when it is fully expanded.
flexibleSpace Widget?
This widget is stacked behind the toolbar and the tab bar. It's height will be the same as the app bar's overall height.
floating bool
Whether the app bar should become visible as soon as the user scrolls towards the app bar.
forceElevated bool
Whether to show the shadow appropriate for the elevation even if the content is not scrolled under the NewGradientAppBar.
gradient Gradient?
The gradient displayed at the appbar.
hashCode int
The hash code for this object.
iconTheme IconThemeData?
The color, opacity, and size to use for app bar icons. Typically this is set along with backgroundColor, brightness, textTheme.
key Key?
Controls how one widget replaces another widget in the tree.
leading Widget?
A widget to display before the title.
pinned bool
Whether the app bar should remain visible at the start of the scroll view.
primary bool
Whether this app bar is being displayed at the top of the screen.
runtimeType Type
A representation of the runtime type of the object.
shape ShapeBorder?
The material's shape as well its shadow.
snap bool
If snap and floating are true then the floating app bar will "snap" into view.
textTheme TextTheme?
The typographic styles to use for text in the app bar. Typically this is set along with brightness backgroundColor, iconTheme.
title Widget?
The primary widget displayed in the appbar.
titleSpacing double
The spacing around title content on the horizontal axis. This spacing is applied even if there is no leading content or actions. If you want title to take all the space available, set this value to 0.0.


createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
createState() → _SliverNewGradientAppBarState
Creates the mutable state for this widget at a given location in the tree.
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
toString({DiagnosticLevel minLevel =}) String
A string representation of this object.
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
toStringShort() String
A short, textual description of this widget.


operator ==(Object other) bool
The equality operator.