lerpColor static method

Linearly interpolate between two FWidgetStateMaps of Colors.

Constraint operand order matters

TL;DR: Always make sure that constraint operands are exactly the same across a and b.

WidgetStatesConstraints are not commutative. Reversed constraint operands (like .hovered & .pressed vs .pressed & .hovered) are treated as distinct keys.

For each constraint in either map, lerp is called with the values from both maps, using null for missing values.

WidgetState.pressed && Widget
final a = FWidgetStateMap<double>({
  WidgetState.pressed: 1.0,
  WidgetState.hovered & Widget.focused: 0.8,
});

final b = FWidgetStateMap<double>({
  WidgetState.pressed: 0.5,
  WidgetState.focused & Widget.focused: 0.9,
});

final result = FWidgetStateMap.lerpWhere(a, b, 0.5, lerpDouble);
// Result contains:
// - .pressed: 0.75 (lerp between 1.0 and 0.5)
// - .hovered & .focused: 0.4 (lerp between 0.8 and null)
// - .focused & .hovered: 0.45 (lerp between null and 0.9)

As resolve treats state combinations as equivalent regardless of order, {.hovered & .focused} will always return 0.4, the first matching constraint, and never 0.45, the last matching constraint.

Implementation

static FWidgetStateMap<Color> lerpColor(FWidgetStateMap<Color> a, FWidgetStateMap<Color> b, double t) =>
    lerpWhere(a, b, t, Color.lerp);