lerpWith method

  1. @override
MantleTypography lerpWith(
  1. covariant MantleTypography other,
  2. double t
)
override

Linearly interpolates between this group and other.

Returns this group when t is 0 and other when t is 1. Fields that cannot be interpolated snap to other when t is 0.5 or greater.

Implementation

@override
MantleTypography lerpWith(covariant MantleTypography other, double t) {
  if (isEmpty) {
    return other;
  }
  if (other.isEmpty) {
    return this;
  }
  final snap = t < 0.5 ? this : other;
  return MantleTypography(
    fontFamily: snap.fontFamily,
    fontFamilyMono: snap.fontFamilyMono,
    fontSize: fontSize.lerp(other.fontSize, t),
    headings: headings.lerpWith(other.headings, t),
    body: TextStyle.lerp(body, other.body, t)!,
    label: TextStyle.lerp(label, other.label, t)!,
    lineHeight: lineHeight.lerp(other.lineHeight, t),
  );
}