calculateVerticalLayoutData method
Vertical layout of the events.
Calculates the top and bottom of each event, and ensues that they are within the bounds of the widget.
size - The size of the widget.
Implementation
List<VerticalLayoutData> calculateVerticalLayoutData(Size size) {
final numberOfChildren = events.length;
final currentCache = <int, VerticalLayoutData>{};
final cache = layoutCache.getCache(date, heightPerMinute, timeOfDayRange);
// Collected per child rather than read back out of the cache. The cache is keyed by event hash, so two equal events
// share one entry, and using its values as the result would leave a child with no layout data at all.
final layoutData = <VerticalLayoutData>[];
for (var i = 0; i < numberOfChildren; i++) {
final event = events.elementAt(i);
final eventHash = event.hashCode;
final cached = cache?[eventHash];
final data = cached == null ? _calculateSingleEventLayout(i, size, event) : cached.copyWith(id: i);
layoutData.add(data);
currentCache[eventHash] = data;
}
layoutCache.setCache(date, heightPerMinute, timeOfDayRange, currentCache);
return sortVerticalLayoutData(layoutData);
}