lerp method

SliderThemeData lerp (SliderThemeData a, SliderThemeData b, 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(
    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),
    disabledThumbColor: Color.lerp(a.disabledThumbColor, b.disabledThumbColor, t),
    overlayColor: Color.lerp(a.overlayColor, b.overlayColor, t),
    valueIndicatorColor: Color.lerp(a.valueIndicatorColor, b.valueIndicatorColor, t),
    thumbShape: t < 0.5 ? a.thumbShape : b.thumbShape,
    valueIndicatorShape: t < 0.5 ? a.valueIndicatorShape : b.valueIndicatorShape,
    showValueIndicator: t < 0.5 ? a.showValueIndicator : b.showValueIndicator,
    valueIndicatorTextStyle: TextStyle.lerp(a.valueIndicatorTextStyle, b.valueIndicatorTextStyle, t),
  );
}