segmentDuration method

int segmentDuration(
  1. KalenderTimeRange timeOfDayRange,
  2. double heightPerMinute,
  3. double itemHeight
)

Calculates the segments duration based on the timeOfDayRange, heightPerMinute, and itemHeight.

Implementation

int segmentDuration(KalenderTimeRange timeOfDayRange, double heightPerMinute, double itemHeight) {
  final totalHeight = timeOfDayRange.duration.inMinutes * heightPerMinute;
  final totalItems = (totalHeight / itemHeight).ceil();
  return switch (totalItems) {
    < 12 => 60,
    < 24 => 30,
    < 48 => 15,
    _ => 5,
  };
}