SnackBar constructor

const SnackBar({
  1. Key? key,
  2. required Widget content,
  3. Color? backgroundColor,
  4. double? elevation,
  5. EdgeInsetsGeometry? margin,
  6. EdgeInsetsGeometry? padding,
  7. double? width,
  8. ShapeBorder? shape,
  9. HitTestBehavior? hitTestBehavior,
  10. SnackBarBehavior? behavior,
  11. SnackBarAction? action,
  12. double? actionOverflowThreshold,
  13. bool? showCloseIcon,
  14. Color? closeIconColor,
  15. Duration duration = _snackBarDisplayDuration,
  16. Animation<double>? animation,
  17. VoidCallback? onVisible,
  18. DismissDirection? dismissDirection,
  19. Clip clipBehavior = Clip.hardEdge,
})

Creates a snack bar.

The elevation must be null or non-negative.

Implementation

const SnackBar({
  super.key,
  required this.content,
  this.backgroundColor,
  this.elevation,
  this.margin,
  this.padding,
  this.width,
  this.shape,
  this.hitTestBehavior,
  this.behavior,
  this.action,
  this.actionOverflowThreshold,
  this.showCloseIcon,
  this.closeIconColor,
  this.duration = _snackBarDisplayDuration,
  this.animation,
  this.onVisible,
  this.dismissDirection,
  this.clipBehavior = Clip.hardEdge,
}) : assert(elevation == null || elevation >= 0.0),
     assert(width == null || margin == null,
       'Width and margin can not be used together',
     ),
     assert(actionOverflowThreshold == null || (actionOverflowThreshold >= 0 && actionOverflowThreshold <= 1),
      'Action overflow threshold must be between 0 and 1 inclusive');