normalizeSteppedValue function

num normalizeSteppedValue(
  1. num value, {
  2. num? min,
  3. num? max,
  4. num? step,
})

Clamps value to the optional bounds and snaps it to the nearest step.

Step alignment is anchored at min, or at zero when min is absent. Exact ties choose the higher step. When a bound falls between steps, the returned value stays on the nearest valid step inside that bound. Configurations whose step grid cannot be represented finitely throw ArgumentError instead of returning an off-grid value.

Implementation

num normalizeSteppedValue(
  num value, {
  num? min,
  num? max,
  num? step,
}) {
  validateNumericConstraints(min: min, max: max, step: step);
  _validateFinite(value, 'value');

  return _normalizeValidatedValue(value, min: min, max: max, step: step);
}