shadow method

List<BoxShadow> shadow({
  1. num elevation = 4,
  2. Color? color,
  3. BlurStyle blurStyle = BlurStyle.normal,
})

创建 Element 阴影,它会在四周平稳散开,一共支持 8 个层级

Implementation

List<BoxShadow> shadow({
  num elevation = 4,
  Color? color,
  BlurStyle blurStyle = BlurStyle.normal,
}) {
  color ??= Colors.black;
  final e = elevation.toInt() - 1;
  if (e < 0 || e > 8) return [];
  return _blurRadiusList[e]
      .mapIndexed(
        (index, blurRadius) => BoxShadow(
          blurStyle: blurStyle,
          offset: const Offset(0, 0),
          blurRadius: blurRadius,
          spreadRadius: 0,
          color: color!.withValues(alpha: _colorOpacityList[index]),
        ),
      )
      .toList();
}