lerp method

  1. @override
DraftModeUIThemeData lerp(
  1. covariant DraftModeUIThemeData? other,
  2. double t
)
override

Linearly interpolate with another ThemeExtension object.

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

@override
DraftModeUIThemeData lerp(
  covariant DraftModeUIThemeData? other,
  double t,
) {
  if (other == null) return this;
  if (identical(this, other)) return this;

  return DraftModeUIThemeData(
    platformStyle: t < 0.5 ? platformStyle : other.platformStyle,
    brightness: t < 0.5 ? brightness : other.brightness,
    primaryColor: ColorRole.lerp(primaryColor, other.primaryColor, t)!,
    secondaryColor: ColorRole.lerp(secondaryColor, other.secondaryColor, t)!,
    tertiaryColor: ColorRole.lerp(tertiaryColor, other.tertiaryColor, t)!,
    accentColor: Color.lerp(accentColor, other.accentColor, t)!,
    dangerColor: Color.lerp(dangerColor, other.dangerColor, t)!,
    successColor: Color.lerp(successColor, other.successColor, t)!,
    warningColor: Color.lerp(warningColor, other.warningColor, t)!,
    buttonGrayColor:
        ColorRole.lerp(buttonGrayColor, other.buttonGrayColor, t)!,
    separatorColor: Color.lerp(separatorColor, other.separatorColor, t)!,
    switchAndroidActiveTrackColor: Color.lerp(
      switchAndroidActiveTrackColor,
      other.switchAndroidActiveTrackColor,
      t,
    )!,
    switchAndroidActiveThumbColor: Color.lerp(
      switchAndroidActiveThumbColor,
      other.switchAndroidActiveThumbColor,
      t,
    )!,
    switchAndroidInactiveTrackColor: Color.lerp(
      switchAndroidInactiveTrackColor,
      other.switchAndroidInactiveTrackColor,
      t,
    )!,
    switchAndroidInactiveThumbColor: Color.lerp(
      switchAndroidInactiveThumbColor,
      other.switchAndroidInactiveThumbColor,
      t,
    )!,
    switchAndroidTrackOutlineColor: Color.lerp(
      switchAndroidTrackOutlineColor,
      other.switchAndroidTrackOutlineColor,
      t,
    )!,
    fontSizeXLarge: lerpDouble(fontSizeXLarge, other.fontSizeXLarge, t)!,
    fontSizePrimary: lerpDouble(fontSizePrimary, other.fontSizePrimary, t)!,
    fontSizeSecondary:
        lerpDouble(fontSizeSecondary, other.fontSizeSecondary, t)!,
    fontSizeTertiary:
        lerpDouble(fontSizeTertiary, other.fontSizeTertiary, t)!,
    fontWeightRegular:
        FontWeight.lerp(fontWeightRegular, other.fontWeightRegular, t)!,
    fontWeightMedium:
        FontWeight.lerp(fontWeightMedium, other.fontWeightMedium, t)!,
    fontWeightSemibold:
        FontWeight.lerp(fontWeightSemibold, other.fontWeightSemibold, t)!,
    sectionHeaderFontSize:
        lerpDouble(sectionHeaderFontSize, other.sectionHeaderFontSize, t)!,
    sectionHeaderFontWeight: FontWeight.lerp(
      sectionHeaderFontWeight,
      other.sectionHeaderFontWeight,
      t,
    )!,
    sectionHeaderLetterSpacing: lerpDouble(
      sectionHeaderLetterSpacing,
      other.sectionHeaderLetterSpacing,
      t,
    )!,
    spacingXs: lerpDouble(spacingXs, other.spacingXs, t)!,
    spacingSm: lerpDouble(spacingSm, other.spacingSm, t)!,
    spacingMd: lerpDouble(spacingMd, other.spacingMd, t)!,
    spacingLg: lerpDouble(spacingLg, other.spacingLg, t)!,
    spacingXl: lerpDouble(spacingXl, other.spacingXl, t)!,
    radiusPrimary: lerpDouble(radiusPrimary, other.radiusPrimary, t)!,
    radiusSecondary: lerpDouble(radiusSecondary, other.radiusSecondary, t)!,
    radiusPill: lerpDouble(radiusPill, other.radiusPill, t)!,
    iconSizeLarge: lerpDouble(iconSizeLarge, other.iconSizeLarge, t)!,
    iconSizeMedium: lerpDouble(iconSizeMedium, other.iconSizeMedium, t)!,
    iconSizeSmall: lerpDouble(iconSizeSmall, other.iconSizeSmall, t)!,
    navBarTopHeight: lerpDouble(navBarTopHeight, other.navBarTopHeight, t)!,
    navBarTopIconHeight:
        lerpDouble(navBarTopIconHeight, other.navBarTopIconHeight, t)!,
    navBarBottomHeight:
        lerpDouble(navBarBottomHeight, other.navBarBottomHeight, t)!,
    navBarBottomIconHeight:
        lerpDouble(navBarBottomIconHeight, other.navBarBottomIconHeight, t)!,
    buttonLarge: t < 0.5 ? buttonLarge : other.buttonLarge,
    buttonMedium: t < 0.5 ? buttonMedium : other.buttonMedium,
    buttonSmall: t < 0.5 ? buttonSmall : other.buttonSmall,
    rowMinHeight: lerpDouble(rowMinHeight, other.rowMinHeight, t)!,
    rowPaddingHorizontal:
        lerpDouble(rowPaddingHorizontal, other.rowPaddingHorizontal, t)!,
    labelWidth: lerpDouble(labelWidth, other.labelWidth, t)!,
    rowLabelFontSize:
        lerpDouble(rowLabelFontSize, other.rowLabelFontSize, t)!,
    rowLabelFontWeight:
        FontWeight.lerp(rowLabelFontWeight, other.rowLabelFontWeight, t)!,
    rowTextFontSize: lerpDouble(rowTextFontSize, other.rowTextFontSize, t)!,
    rowTextFontWeight:
        FontWeight.lerp(rowTextFontWeight, other.rowTextFontWeight, t)!,
    disclosureColor: Color.lerp(disclosureColor, other.disclosureColor, t)!,
    disclosureSize: lerpDouble(disclosureSize, other.disclosureSize, t)!,
    separatorHeight: lerpDouble(separatorHeight, other.separatorHeight, t)!,
    shadowColor: Color.lerp(shadowColor, other.shadowColor, t)!,
    shadowBlurRadius:
        lerpDouble(shadowBlurRadius, other.shadowBlurRadius, t)!,
    toastBottomOffset:
        lerpDouble(toastBottomOffset, other.toastBottomOffset, t)!,
    toastOpacity: lerpDouble(toastOpacity, other.toastOpacity, t)!,
    toastMaxWidth: lerpDouble(toastMaxWidth, other.toastMaxWidth, t)!,
    toastHorizontalInset:
        lerpDouble(toastHorizontalInset, other.toastHorizontalInset, t)!,
    toastRadius: lerpDouble(toastRadius, other.toastRadius, t)!,
    toastMinHeight: lerpDouble(toastMinHeight, other.toastMinHeight, t)!,
    toastPaddingHorizontal:
        lerpDouble(toastPaddingHorizontal, other.toastPaddingHorizontal, t)!,
    toastPaddingVertical:
        lerpDouble(toastPaddingVertical, other.toastPaddingVertical, t)!,
    toastShadowColor:
        Color.lerp(toastShadowColor, other.toastShadowColor, t)!,
    toastShadowBlurRadius:
        lerpDouble(toastShadowBlurRadius, other.toastShadowBlurRadius, t)!,
    badgeMinSize: lerpDouble(badgeMinSize, other.badgeMinSize, t)!,
    badgeRadius: lerpDouble(badgeRadius, other.badgeRadius, t)!,
    badgePaddingHorizontal:
        lerpDouble(badgePaddingHorizontal, other.badgePaddingHorizontal, t)!,
    badgePaddingVertical:
        lerpDouble(badgePaddingVertical, other.badgePaddingVertical, t)!,
    badgeOffsetTop: lerpDouble(badgeOffsetTop, other.badgeOffsetTop, t)!,
    badgeOffsetRight:
        lerpDouble(badgeOffsetRight, other.badgeOffsetRight, t)!,
    spinnerAndroidStrokeWidth: lerpDouble(
      spinnerAndroidStrokeWidth,
      other.spinnerAndroidStrokeWidth,
      t,
    )!,
    dropDownMenuMinWidth:
        lerpDouble(dropDownMenuMinWidth, other.dropDownMenuMinWidth, t)!,
    dropDownMenuMaxWidth:
        lerpDouble(dropDownMenuMaxWidth, other.dropDownMenuMaxWidth, t)!,
    dropDownMenuGap: lerpDouble(dropDownMenuGap, other.dropDownMenuGap, t)!,
    animationDurationFast:
        t < 0.5 ? animationDurationFast : other.animationDurationFast,
    animationDurationDefault:
        t < 0.5 ? animationDurationDefault : other.animationDurationDefault,
    animationCurve: t < 0.5 ? animationCurve : other.animationCurve,
  );
}