lerpColor static method

Color? lerpColor(
  1. Color? a,
  2. Color? b,
  3. double t
)

Linearly interpolates between two colors a and b using the given factor t.

Both colors are converted to Display P3 if they do not share the same color space.

Implementation

static Color? lerpColor(Color? a, Color? b, double t) {
  if (a != null && b != null && a.colorSpace != b.colorSpace) {
    a = a.withValues(colorSpace: .displayP3);
    b = b.withValues(colorSpace: .displayP3);
  }

  return Color.lerp(a, b, t);
}