lerp method
Returns the value this variable has at the given animation clock value.
The default implementation of this method uses the +
, -
, and *
operators on T
. The begin and end properties must therefore be
non-null by the time this method is called.
In general, however, it is possible for this to return null, especially
when t
=0.0 and begin is null, or t
=1.0 and end is null.
Implementation
@override
BoxDecoration? lerp(double t) {
if (begin == null && end == null) return null;
if (begin == null) return end!.scale(t);
if (end == null) return begin!.scale(1.0 - t);
if (t == 0.0) return begin;
if (t == 1.0) return end;
return BoxDecoration(
color: Color.lerp(begin!.color, end!.color, t),
gradient: lerpGradientWithColor(
begin!.gradient, end!.gradient, begin!.color, end!.color, t),
image: t < 0.5
? begin!.image
: end!.image, // TODO(ianh): cross-fade the image
border: BoxBorder.lerp(begin!.border, end!.border, t),
borderRadius:
BorderRadiusGeometry.lerp(begin!.borderRadius, end!.borderRadius, t),
boxShadow: BoxShadow.lerpList(begin!.boxShadow, end!.boxShadow, t),
shape: t < 0.5 ? begin!.shape : end!.shape,
);
}