Material constructor Null safety

const Material(
  1. {Key? key,
  2. MaterialType type = MaterialType.canvas,
  3. double elevation = 0.0,
  4. Color? color,
  5. Color? shadowColor,
  6. Color? surfaceTintColor,
  7. TextStyle? textStyle,
  8. BorderRadiusGeometry? borderRadius,
  9. ShapeBorder? shape,
  10. bool borderOnForeground = true,
  11. Clip clipBehavior = Clip.none,
  12. Duration animationDuration = kThemeChangeDuration,
  13. Widget? child}
)

Creates a piece of material.

The type, elevation, borderOnForeground, clipBehavior, and animationDuration arguments must not be null. Additionally, elevation must be non-negative.

If a shape is specified, then the borderRadius property must be null and the type property must not be MaterialType.circle. If the borderRadius is specified, then the type property must not be MaterialType.circle. In both cases, these restrictions are intended to catch likely errors.

Implementation

const Material({
  super.key,
  this.type = MaterialType.canvas,
  this.elevation = 0.0,
  this.color,
  this.shadowColor,
  this.surfaceTintColor,
  this.textStyle,
  this.borderRadius,
  this.shape,
  this.borderOnForeground = true,
  this.clipBehavior = Clip.none,
  this.animationDuration = kThemeChangeDuration,
  this.child,
}) : assert(type != null),
     assert(elevation != null && elevation >= 0.0),
     assert(!(shape != null && borderRadius != null)),
     assert(animationDuration != null),
     assert(!(identical(type, MaterialType.circle) && (borderRadius != null || shape != null))),
     assert(borderOnForeground != null),
     assert(clipBehavior != null);