shadows static method

List<BoxShadow> shadows(
  1. double elevation, {
  2. Color? shadowColor,
})

Builds the layered key + ambient shadows Material uses for elevation.

Returns an empty list at level 0 so no shadow is painted.

Implementation

static List<BoxShadow> shadows(double elevation, {Color? shadowColor}) {
  if (elevation <= 0) {
    return const <BoxShadow>[];
  }
  final Color color = shadowColor ?? const Color(0xFF000000);
  return <BoxShadow>[
    BoxShadow(
      color: color.withValues(alpha: 0.3),
      offset: Offset(0, elevation * 0.5),
      blurRadius: elevation,
      spreadRadius: -elevation * 0.5,
    ),
    BoxShadow(
      color: color.withValues(alpha: 0.15),
      offset: Offset(0, elevation),
      blurRadius: elevation * 2,
    ),
  ];
}