GlassAppBar.pinned constructor
- Key? key,
- Widget? title,
- List<
GlassBarItem> leading = const [], - List<
GlassBarItem> actions = const [], - bool backButton = true,
- bool leadingItemsSupplementBackButton = false,
- VoidCallback? onBack,
- double? buttonSize,
- bool centerTitle = true,
- Color backgroundColor = const Color(0x00000000),
- double toolbarHeight = 44.0,
- EdgeInsetsGeometry? padding,
- LiquidGlassSettings? buttonSettings,
- GlassLargeTitleController? largeTitleController,
- PreferredSizeWidget? bottom,
- bool groupBackdrop = true,
Creates a glass app bar whose chrome pins above the Navigator.
Inside a GlassNavigationShell, the automatic back button and the
actions capsule stay put while the page slides during push and pop,
morphing in place into the next route's items — the iOS 26 navigation
bar behaviour. Without a shell (or where the effect cannot render) the
same items render inside this bar, so screens work either way.
leading and actions are declared as data (GlassBarItem), mirroring
UIBarButtonItem — there is no widget-based leading/actions in this
mode, because arbitrary widgets cannot be hoisted to the shell. Items
sharing an id across routes morph as the same item; see
GlassBarItem.icon.
The back button appears whenever the route can be popped and never on a
root route. A non-empty leading replaces it — UIKit's rule for
leftBarButtonItems, and Flutter's for AppBar.leading, which implies a
leading only when none was given. Set
leadingItemsSupplementBackButton to show both, mirroring
UINavigationItem.leftItemsSupplementBackButton. Set backButton to
false to suppress the back button outright, and onBack to replace its
default Navigator.maybePop() — for example with go_router's
context.pop().
Implementation
const GlassAppBar.pinned({
super.key,
this.title,
List<GlassBarItem> leading = const [],
List<GlassBarItem> actions = const [],
bool backButton = true,
bool leadingItemsSupplementBackButton = false,
this.onBack,
this.buttonSize,
this.centerTitle = true,
// Whitelisted: Structural transparent default, not a Material colour.
this.backgroundColor = const Color(0x00000000),
this.toolbarHeight = 44.0,
EdgeInsetsGeometry? padding,
this.buttonSettings,
this.largeTitleController,
this.bottom,
this.groupBackdrop = true,
}) : assert(buttonSize == null || buttonSize > 0),
padding = padding ?? const EdgeInsets.symmetric(horizontal: 8),
_explicitPinnedPadding = padding,
pinnedActions = actions,
pinnedLeading = leading,
pinnedBackButton = backButton,
pinnedLeadingItemsSupplementBackButton =
leadingItemsSupplementBackButton,
leading = null,
actions = null;