snapToInterval method

int snapToInterval(
  1. int minutes
)

Snaps minutes to a multiple of activeSnapMinutes. The single snapping primitive shared by create (getTimeAtPos) and drag/resize (Event.endDrag), so the two stay in lockstep. An interval <= 1 leaves minutes untouched (minute precision); it truncates rather than rounds so a within-hour offset can't spill into the next hour (e.g. 58 -> 45, never 60, at a 15-minute snap).

Implementation

int snapToInterval(int minutes) {
  final step = activeSnapMinutes;
  if (step <= 1) return minutes;
  return (minutes ~/ step) * step;
}