lerp method Null safety

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

Linearly interpolate between two text themes.

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 TextTheme lerp(TextTheme? a, TextTheme? b, double t) {
  assert(t != null);
  return TextTheme(
    displayLarge: TextStyle.lerp(a?.displayLarge, b?.displayLarge, t),
    displayMedium: TextStyle.lerp(a?.displayMedium, b?.displayMedium, t),
    displaySmall: TextStyle.lerp(a?.displaySmall, b?.displaySmall, t),
    headlineLarge: TextStyle.lerp(a?.headlineLarge, b?.headlineLarge, t),
    headlineMedium: TextStyle.lerp(a?.headlineMedium, b?.headlineMedium, t),
    headlineSmall: TextStyle.lerp(a?.headlineSmall, b?.headlineSmall, t),
    titleLarge: TextStyle.lerp(a?.titleLarge, b?.titleLarge, t),
    titleMedium: TextStyle.lerp(a?.titleMedium, b?.titleMedium, t),
    titleSmall: TextStyle.lerp(a?.titleSmall, b?.titleSmall, t),
    bodyLarge: TextStyle.lerp(a?.bodyLarge, b?.bodyLarge, t),
    bodyMedium: TextStyle.lerp(a?.bodyMedium, b?.bodyMedium, t),
    bodySmall: TextStyle.lerp(a?.bodySmall, b?.bodySmall, t),
    labelLarge: TextStyle.lerp(a?.labelLarge, b?.labelLarge, t),
    labelMedium: TextStyle.lerp(a?.labelMedium, b?.labelMedium, t),
    labelSmall: TextStyle.lerp(a?.labelSmall, b?.labelSmall, t),
  );
}