GlassAppBar.pinned constructor

const GlassAppBar.pinned({
  1. Key? key,
  2. Widget? title,
  3. List<GlassBarItem> leading = const [],
  4. List<GlassBarItem> actions = const [],
  5. bool backButton = true,
  6. bool leadingItemsSupplementBackButton = false,
  7. VoidCallback? onBack,
  8. double? buttonSize,
  9. bool centerTitle = true,
  10. Color backgroundColor = const Color(0x00000000),
  11. double toolbarHeight = 44.0,
  12. EdgeInsetsGeometry? padding,
  13. LiquidGlassSettings? buttonSettings,
  14. GlassLargeTitleController? largeTitleController,
  15. PreferredSizeWidget? bottom,
  16. 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;