SnackBar constructor Null safety

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. SnackBarBehavior? behavior,
  10. SnackBarAction? action,
  11. Duration duration = _snackBarDisplayDuration,
  12. Animation<double>? animation,
  13. VoidCallback? onVisible,
  14. DismissDirection dismissDirection = DismissDirection.down,
  15. Clip clipBehavior = Clip.hardEdge}
)

Creates a snack bar.

The content argument must be non-null. The elevation must be null or non-negative.

Implementation

const SnackBar({
  Key? key,
  required this.content,
  this.backgroundColor,
  this.elevation,
  this.margin,
  this.padding,
  this.width,
  this.shape,
  this.behavior,
  this.action,
  this.duration = _snackBarDisplayDuration,
  this.animation,
  this.onVisible,
  this.dismissDirection = DismissDirection.down,
  this.clipBehavior = Clip.hardEdge,
}) : assert(elevation == null || elevation >= 0.0),
     assert(content != null),
     assert(
       width == null || margin == null,
       'Width and margin can not be used together',
     ),
     assert(duration != null),
     assert(clipBehavior != null),
     super(key: key);