ShapeDecoration constructor Null safety

const ShapeDecoration(
  1. {Color? color,
  2. DecorationImage? image,
  3. Gradient? gradient,
  4. List<BoxShadow>? shadows,
  5. required ShapeBorder shape}
)

Creates a shape decoration.

  • If color is null, this decoration does not paint a background color.
  • If gradient is null, this decoration does not paint gradients.
  • If image is null, this decoration does not paint a background image.
  • If shadows is null, this decoration does not paint a shadow.

The color and gradient properties are mutually exclusive, one (or both) of them must be null.

The shape must not be null.

Implementation

const ShapeDecoration({
  this.color,
  this.image,
  this.gradient,
  this.shadows,
  required this.shape,
}) : assert(!(color != null && gradient != null)),
     assert(shape != null);