ExpressiveShellAction constructor

const ExpressiveShellAction({
  1. IconData? icon,
  2. void onPressed(
    1. BuildContext context
    )?,
  3. String? label,
  4. bool accent = false,
  5. List<ExpressiveFabMenuItem>? menu,
  6. bool scrim = false,
  7. String? semanticLabel,
  8. bool splashAnchor = false,
  9. bool? expanded,
  10. ValueChanged<bool>? onExpandedChanged,
  11. ShellAction? action,
  12. Widget? mark,
  13. bool collapseOnScroll = false,
  14. bool labelShown = true,
  15. Key? key,
})

A spec (icon with onPressed, or a menu), or — with action — the widget that draws action. onPressed is handed the context it was pressed in.

Implementation

const ExpressiveShellAction({
  IconData? icon,
  void Function(BuildContext context)? onPressed,
  this.label,
  this.accent = false,
  this.menu,
  this.scrim = false,
  this.semanticLabel,
  this.splashAnchor = false,
  this.expanded,
  this.onExpandedChanged,
  this.action,
  this.mark,
  this.collapseOnScroll = false,
  this.labelShown = true,
  super.key,
}) : _icon = icon,
     _onPressed = onPressed,
     assert(
       (action == null) != (icon == null),
       'ExpressiveShellAction is a spec (icon:) or draws one (action:).',
     ),
     assert(
       action != null || onPressed != null || menu != null,
       'An ExpressiveShellAction without a menu needs onPressed.',
     ),
     assert(
       menu == null || label == null,
       'A FAB menu never opens from an extended FAB (CONTRACT §3): give '
       'the action a label or a menu, not both.',
     ),
     assert(
       menu == null || (menu.length >= 2 && menu.length <= 5),
       'A FAB menu holds 2–5 items (CONTRACT §3).',
     ),
     assert(!scrim || menu != null, 'Only a FAB menu dims the screen.'),
     assert(
       expanded == null || menu != null,
       'Only a FAB menu opens: expanded needs a menu.',
     ),
     assert(
       !collapseOnScroll || label != null || action != null,
       'Only an extended FAB collapses: collapseOnScroll needs a label.',
     );