buildIconShadows function

  1. @visibleForTesting
List<Shadow>? buildIconShadows({
  1. required Color iconColor,
  2. required double? thickness,
  3. required bool selected,
  4. required Widget? activeIcon,
})

Builds multi-directional icon shadows that simulate a stroke/outline effect.

Returns null (no shadow) when:

  • thickness is null (feature not requested), or
  • selected is true AND activeIcon is non-null (distinct active icon is used so outline shadow is not needed in that state).

Otherwise, generates 8 evenly-spaced Shadow offsets around the icon at the given thickness radius using 45° increments.

Extracted from BottomBarTabItem to enable isolated unit testing.

Implementation

@visibleForTesting
List<Shadow>? buildIconShadows({
  required Color iconColor,
  required double? thickness,
  required bool selected,
  required Widget? activeIcon,
}) {
  if (thickness == null || (selected && activeIcon != null)) return null;
  final shadows = <Shadow>[];
  const step = math.pi / 4;
  for (double a = 0; a < math.pi * 2; a += step) {
    shadows.add(Shadow(
      color: iconColor,
      offset: Offset.fromDirection(a, thickness),
    ));
  }
  return shadows;
}