SliverAppBar.medium constructor

const SliverAppBar.medium(
  1. {Key? key,
  2. Widget? leading,
  3. bool automaticallyImplyLeading = true,
  4. Widget? title,
  5. List<Widget>? actions,
  6. Widget? flexibleSpace,
  7. PreferredSizeWidget? bottom,
  8. double? elevation,
  9. double? scrolledUnderElevation,
  10. Color? shadowColor,
  11. Color? surfaceTintColor,
  12. bool forceElevated = false,
  13. Color? backgroundColor,
  14. Color? foregroundColor,
  15. IconThemeData? iconTheme,
  16. IconThemeData? actionsIconTheme,
  17. bool primary = true,
  18. bool? centerTitle,
  19. bool excludeHeaderSemantics = false,
  20. double? titleSpacing,
  21. double? collapsedHeight,
  22. double? expandedHeight,
  23. bool floating = false,
  24. bool pinned = true,
  25. bool snap = false,
  26. bool stretch = false,
  27. double stretchTriggerOffset = 100.0,
  28. AsyncCallback? onStretchTrigger,
  29. ShapeBorder? shape,
  30. double toolbarHeight = _MediumScrollUnderFlexibleConfig.collapsedHeight,
  31. double? leadingWidth,
  32. TextStyle? toolbarTextStyle,
  33. TextStyle? titleTextStyle,
  34. SystemUiOverlayStyle? systemOverlayStyle,
  35. bool forceMaterialTransparency = false,
  36. Clip? clipBehavior}
)

Creates a Material Design medium top app bar that can be placed in a CustomScrollView.

Returns a SliverAppBar configured with appropriate defaults for a medium top app bar as defined in Material 3. It starts fully expanded with the title in an area underneath the main row of icons. When the CustomScrollView is scrolled, the title will be scrolled under the main row. When it is fully collapsed, a smaller version of the title will fade in on the main row. The reverse will happen if it is expanded again.

This sample shows how to use SliverAppBar.medium in a CustomScrollView.
link

To create a local project with this code sample, run:
flutter create --sample=material.SliverAppBar.medium.1 mysample

See also:

Implementation

const SliverAppBar.medium({
  super.key,
  this.leading,
  this.automaticallyImplyLeading = true,
  this.title,
  this.actions,
  this.flexibleSpace,
  this.bottom,
  this.elevation,
  this.scrolledUnderElevation,
  this.shadowColor,
  this.surfaceTintColor,
  this.forceElevated = false,
  this.backgroundColor,
  this.foregroundColor,
  this.iconTheme,
  this.actionsIconTheme,
  this.primary = true,
  this.centerTitle,
  this.excludeHeaderSemantics = false,
  this.titleSpacing,
  this.collapsedHeight,
  this.expandedHeight,
  this.floating = false,
  this.pinned = true,
  this.snap = false,
  this.stretch = false,
  this.stretchTriggerOffset = 100.0,
  this.onStretchTrigger,
  this.shape,
  this.toolbarHeight = _MediumScrollUnderFlexibleConfig.collapsedHeight,
  this.leadingWidth,
  this.toolbarTextStyle,
  this.titleTextStyle,
  this.systemOverlayStyle,
  this.forceMaterialTransparency = false,
  this.clipBehavior,
 }) : assert(floating || !snap, 'The "snap" argument only makes sense for floating app bars.'),
     assert(stretchTriggerOffset > 0.0),
     assert(
      collapsedHeight == null || collapsedHeight >= toolbarHeight,
      'The "collapsedHeight" argument has to be larger than or equal to [toolbarHeight].',
     ),
     _variant = _SliverAppVariant.medium;