GlassScaffold class Panels and controls

A screen: a body that scrolls under a glass topBar, with an optional bottomBar and floatingAction, under a GlassHost.

GlassScaffold(
  topBar: const GlassBar(
    child: Row(
      children: <Widget>[Icon(Icons.arrow_back), SizedBox(width: 12), Text('Library')],
    ),
  ),
  bottomBar: GlassTabBar(
    items: const <GlassTabItem>[
      GlassTabItem(icon: Icons.home, label: 'Home'),
      GlassTabItem(icon: Icons.search, label: 'Search'),
    ],
    selectedIndex: tab,
    onSelected: (int i) => setState(() => tab = i),
  ),
  // Takes its padding from the media query: starts below the top bar,
  // ends above the tab bar, and scrolls under both.
  body: ListView.builder(itemCount: 50, itemBuilder: buildRow),
)

The host. By default the scaffold mounts a GlassHost only when there is none above it (host). The one it mounts takes every default; to declare anything — a backdrop, a finish, the appearance of an app whose theme does not follow the phone's, the hardware, a ripple — put your own host above and the scaffold uses it. Dialogs, sheets and menus are built in the navigator's overlay, so they need the host above the navigator (MaterialApp.builder); a host the scaffold mounts is inside the route and does not reach them.

The body fills the whole scaffold and is told the bars' extents as MediaQuery.padding — top and bottom, never less than the safe area's — which is what lets it scroll under them. A body that is not a scroll view can read the same padding, or wrap itself in a SafeArea.

The keyboard, as Scaffold meets it: by default (resizeToAvoidBottomInset) the body ends at the keyboard's top and is told no bottom inset, so a focused field in a scroll view is scrolled into sight, and the floating action stands on the keyboard. The bottom bar stays at the bottom, under the keyboard, as a tab bar does on iOS.

A tab bar that collapses on scroll. The scaffold is a GlassTabBarMinimizer: a GlassTabBar in bottomBar with minimizeBehavior: GlassTabBarMinimizeBehavior.onScrollDown collapses to its selected tab when the body scrolls down and expands when it scrolls up. Its box keeps its height, so the body's padding does not move. A body whose lists are nested in another scroll view — a PageView, a TabBarView — reaches it through minimizeNotificationPredicate.

Note: every frame of a scroll is one capture of the whole host, for every glass on the screen at once, because the content under the bars changes; a still screen is held. Over glass cards, the lifted bars add one snapshot to each frame that records.

See also:

Inheritance

Constructors

GlassScaffold({required Widget body, Widget? topBar, double topBarHeight = kGlassScaffoldBarHeight, GlassScrollEdgeStyle? scrollEdge = GlassScrollEdgeStyle.soft, Widget? bottomBar, Widget? floatingAction, EdgeInsetsGeometry barMargin = kGlassScaffoldBarMargin, bool? host, ScrollNotificationPredicate minimizeNotificationPredicate = defaultScrollNotificationPredicate, bool resizeToAvoidBottomInset = true, Key? key})
A screen of body, with whichever of topBar, bottomBar and floatingAction are given. topBarHeight must not be negative.
const

Properties

barMargin → EdgeInsetsGeometry
The space around each bar, inside the safe area: the top bar's top and sides and the gap under it, the bottom bar's sides and the gap above it. Under the bottom bar it is the larger of this and the safe area. An EdgeInsetsDirectional is resolved with the ambient Directionality, left to right without one.
final
body → Widget
The screen's content: laid out under the whole scaffold, and told the bars' extents through MediaQuery.padding.
final
bottomBar → Widget?
The bar at the bottom — usually a GlassTabBar — at its own height, the scaffold's width less barMargin and the safe area, and lifted. Null for none.
final
floatingAction → Widget?
A control floating at the end edge, above bottomBar — usually a GlassButton — at its own size, and lifted. Null for none.
final
hashCode → int
The hash code for this object.
no setterinherited
host → bool?
Whether the scaffold mounts a GlassHost of its own: null (the default) when there is none above it, true always, false never.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
minimizeNotificationPredicate → ScrollNotificationPredicate
Which of body's scroll notifications collapse a GlassTabBar in bottomBar: the scaffold's GlassTabBarMinimizer.notificationPredicate. By default the body's own scroll view's; a body that is a PageView or a TabBarView of lists, or a NestedScrollView, has its lists one deeper, and (ScrollNotification n) => n.depth == 1 reaches them.
final
resizeToAvoidBottomInset → bool
Whether the body ends at the keyboard's top, as Scaffold's does: it is laid out that much shorter, told no bottom viewInsets, and padded only for what of the bottom bar shows above the keyboard. The floating action stands on the keyboard too. False lays the body out under the keyboard and passes MediaQuery.viewInsets on as it is. The bottom bar is under the keyboard either way.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scrollEdge → GlassScrollEdgeStyle?
The scroll edge effect under topBar, or null for none — the bar is then lifted (GlassAbove) and nothing else.
final
topBar → Widget?
The bar at the top — usually a GlassBar — laid out topBarHeight tall and the scaffold's width less barMargin and the safe area. Null for no top bar and no scroll edge.
final
topBarHeight → double
The height topBar is laid out in, logical px. Declared rather than measured, because the scroll edge under the bar is laid out from it.
final

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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
topExtentFor(EdgeInsets safe) → double
The top bar's extent from the top of the screen, logical px: the safe area, barMargin above and below, and topBarHeight. What the body is told as its top padding, and the scroll edge's GlassScrollEdge.extent.
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