lerp method

Linearly interpolates this theme's values with other.

Implementation

SmoothPageIndicatorTheme lerp(
  SmoothPageIndicatorTheme? other,
  double t,
) {
  if (other is! SmoothPageIndicatorTheme) {
    return this;
  }

  // Lerp effects if both are non-null and same type
  IndicatorEffect? lerpedEffect;
  if (effect != null &&
      other.effect != null &&
      effect.runtimeType == other.effect.runtimeType) {
    lerpedEffect = effect!.lerp(other.effect, t);
  } else {
    lerpedEffect = t < 0.5 ? effect : other.effect;
  }

  // Lerp colors if both are non-null
  final lerpedColors = defaultColors?.lerp(other.defaultColors, t) ??
      (t < 0.5 ? null : other.defaultColors);

  return SmoothPageIndicatorTheme(
    effect: lerpedEffect,
    defaultColors: lerpedColors,
    child: t < 0.5 ? child : other.child,
  );
}