boxShadows static method
TODO: Write more details.
See BoxShadow.scale for the usage of double scale
.
Use offsetScalar
to make the effect less dramatic and scale the offsets
for use as a textStyle for example.
Implementation
static List<BoxShadow> boxShadows({
required Color color,
required int depth,
Curvature curvature = Curvature.convex,
Swell swell = Swell.emboss,
double spread = defaultSpread,
Alignment lightSource = defaultLightSource,
double scale = 1.0,
double offsetScalar = 1.0,
}) {
final isSwollen = swell.isSwollen;
final clampedSpread = spread.clamp(0, 999).toDouble();
final scaledSpread = clampedSpread * offsetScalar;
final lightOffset = isSwollen ? scaledSpread : -scaledSpread;
final colors = swell.degree == Degree.SUPER
? Curvature.superconvex.colorList(color, swell: swell, depth: depth)
: Curvature.convex.colorList(color, swell: swell, depth: depth);
final lightShadow = BoxShadow(
color: colors[0],
offset: Offset(lightSource.x * lightOffset, lightSource.y * lightOffset),
// spreadRadius: (swell.scalar - 1), // super inflates by 1.5 - 1 = 0.5
blurRadius: clampedSpread,
).scale(scale);
/// [Shadow]s stack vertically in the Z-axis in the order in which they are
/// listed in this iterable. That is, later [Shadow]s are painted on top of
/// earlier ones without blending.
return [
if (!isSwollen) lightShadow,
/// darkShadow:
BoxShadow(
color: colors[2],
offset: Offset(
-(lightSource.x * lightOffset), -(lightSource.y * lightOffset)),
// spreadRadius: (swell.scalar - 1), // super inflates by 1.5 - 1 = 0.5
blurRadius: clampedSpread,
).scale(scale),
if (isSwollen) lightShadow,
];
}