rampOpacity method
Return a new List<BoxShadow>
that mirrors this
one except
the Color.opacity of each BoxShadow will be set to
the double
that matches in index from 📊 stops
.
If 📊 stops
has less entries than this
List,
stops.last
will be applied to the extra BoxShadow
s.
Optionally
Apply a single new 🎨 color
for each
BoxShadow.color in this
simultaneously.
Implementation
List<BoxShadow> rampOpacity(List<double> stops, {Color? color}) {
List<BoxShadow> rampedShadows = [];
int i = 0;
for (BoxShadow shadow in this)
rampedShadows.add(
shadow *
(color ?? shadow.color)
// `i-1` since we increment++ when checking against length
.withOpacity((i++ >= stops.length) ? stops.last : stops[i - 1]),
);
return rampedShadows;
}