lerpDiscrete<T> function

T? lerpDiscrete<T>(
  1. T? a,
  2. T? b,
  3. double t
)

Returns a when t is below the halfway point, otherwise b.

The honest interpolation for a value that cannot be blended — an enum, a bool, a callback, a shape. Snapping at the midpoint is what Flutter's own theme classes do for the same case.

Implementation

T? lerpDiscrete<T>(T? a, T? b, double t) => t < 0.5 ? a : b;