lerp method Null safety

SliderThemeData lerp(
  1. SliderThemeData a,
  2. SliderThemeData b,
  3. double t
)

Linearly interpolate between two slider themes.

The arguments must not be null.

The t argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning a (or something equivalent to a), 1.0 meaning that the interpolation has finished, returning b (or something equivalent to b), and values in between meaning that the interpolation is at the relevant point on the timeline between a and b. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves such as Curves.elasticInOut).

Values for t are usually obtained from an Animation<double>, such as an AnimationController.

Implementation

static SliderThemeData lerp(SliderThemeData a, SliderThemeData b, double t) {
  assert(a != null);
  assert(b != null);
  assert(t != null);
  return SliderThemeData(
    trackHeight: lerpDouble(a.trackHeight, b.trackHeight, t),
    activeTrackColor: Color.lerp(a.activeTrackColor, b.activeTrackColor, t),
    inactiveTrackColor: Color.lerp(a.inactiveTrackColor, b.inactiveTrackColor, t),
    disabledActiveTrackColor: Color.lerp(a.disabledActiveTrackColor, b.disabledActiveTrackColor, t),
    disabledInactiveTrackColor: Color.lerp(a.disabledInactiveTrackColor, b.disabledInactiveTrackColor, t),
    activeTickMarkColor: Color.lerp(a.activeTickMarkColor, b.activeTickMarkColor, t),
    inactiveTickMarkColor: Color.lerp(a.inactiveTickMarkColor, b.inactiveTickMarkColor, t),
    disabledActiveTickMarkColor: Color.lerp(a.disabledActiveTickMarkColor, b.disabledActiveTickMarkColor, t),
    disabledInactiveTickMarkColor: Color.lerp(a.disabledInactiveTickMarkColor, b.disabledInactiveTickMarkColor, t),
    thumbColor: Color.lerp(a.thumbColor, b.thumbColor, t),
    overlappingShapeStrokeColor: Color.lerp(a.overlappingShapeStrokeColor, b.overlappingShapeStrokeColor, t),
    disabledThumbColor: Color.lerp(a.disabledThumbColor, b.disabledThumbColor, t),
    overlayColor: Color.lerp(a.overlayColor, b.overlayColor, t),
    valueIndicatorColor: Color.lerp(a.valueIndicatorColor, b.valueIndicatorColor, t),
    overlayShape: t < 0.5 ? a.overlayShape : b.overlayShape,
    tickMarkShape: t < 0.5 ? a.tickMarkShape : b.tickMarkShape,
    thumbShape: t < 0.5 ? a.thumbShape : b.thumbShape,
    trackShape: t < 0.5 ? a.trackShape : b.trackShape,
    valueIndicatorShape: t < 0.5 ? a.valueIndicatorShape : b.valueIndicatorShape,
    rangeTickMarkShape: t < 0.5 ? a.rangeTickMarkShape : b.rangeTickMarkShape,
    rangeThumbShape: t < 0.5 ? a.rangeThumbShape : b.rangeThumbShape,
    rangeTrackShape: t < 0.5 ? a.rangeTrackShape : b.rangeTrackShape,
    rangeValueIndicatorShape: t < 0.5 ? a.rangeValueIndicatorShape : b.rangeValueIndicatorShape,
    showValueIndicator: t < 0.5 ? a.showValueIndicator : b.showValueIndicator,
    valueIndicatorTextStyle: TextStyle.lerp(a.valueIndicatorTextStyle, b.valueIndicatorTextStyle, t),
    minThumbSeparation: lerpDouble(a.minThumbSeparation, b.minThumbSeparation, t),
    thumbSelector: t < 0.5 ? a.thumbSelector : b.thumbSelector,
    mouseCursor: t < 0.5 ? a.mouseCursor : b.mouseCursor,
  );
}