AdaptiveResponsiveScaffold class

A scaffold whose navigation changes shape with the window.

Size class Navigation
compact bottom bar (AdaptiveBottomNav)
medium collapsed side rail
expanded / large expanded sidebar with labels

Both platforms follow that progression, but not with the same widgets: on Material the rail is a NavigationRail and the sidebar a NavigationDrawer; on Cupertino both are a hand-built list, because UIKit's iPad sidebar is a plain grouped list and Material's rail would read as an Android app running on an iPad.

AdaptiveResponsiveScaffold(
  currentIndex: index,
  onIndexChanged: (int i) => setState(() => index = i),
  items: const <NavigationItem>[
    NavigationItem(icon: AdaptiveIcons.home, label: 'Home'),
    NavigationItem(icon: AdaptiveIcons.wallet, label: 'Wallet'),
    NavigationItem(icon: AdaptiveIcons.settings, label: 'Settings'),
  ],
  body: pages[index],
)

Layout only

The window width decides how much navigation is on screen at once. It never decides how large the labels are — those come from AdaptiveTypography, scaled by the user's accessibility setting and nothing else.

Inheritance

Constructors

AdaptiveResponsiveScaffold({Key? key, required int currentIndex, required ValueChanged<int> onIndexChanged, required List<NavigationItem> items, required Widget body, PreferredSizeWidget? appBar, ObstructingPreferredSizeWidget? cupertinoNavigationBar, Color? backgroundColor, Widget? floatingActionButton})
const

Properties

appBar → PreferredSizeWidget?
Material app bar, forwarded to AdaptiveScaffold.
final
backgroundColor → Color?
Background colour of the scaffold.
final
body → Widget
The content next to (or above) the navigation.
final
cupertinoNavigationBar → ObstructingPreferredSizeWidget?
Cupertino navigation bar, forwarded to AdaptiveScaffold.
final
currentIndex → int
Index of the selected destination, into items.
final
floatingActionButton → Widget?
Floating action button, Material only in practice.
final
hashCode → int
The hash code for this object.
no setterinherited
items → List<NavigationItem>
The destinations, in display order. Two to five reads well in a bottom bar; a sidebar tolerates more.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onIndexChanged → ValueChanged<int>
Called with the index of the destination the user picked.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

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
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