Skip to content

Commit

Permalink
Fix MonthPageView's shrinkWrapped height when jumping to far-away date
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasWanke committed Jan 24, 2023
1 parent c0167c2 commit 763661e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/src/date/month_page_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,12 @@ class _MonthPageViewState extends State<MonthPageView> {
final oldMaxHeight = _heights[page.floor()];
final newMaxHeight = _heights[page.ceil()];

// When swiping, the next page might not have been measured yet.
if (oldMaxHeight == null) return newMaxHeight!;
if (newMaxHeight == null) return oldMaxHeight;
// When swiping, the next page might not have been measured yet. When
// jumping to a page that hasn't been measured yet, we might not have any
// heights for that or neighboring pages at all.
if (oldMaxHeight == null || newMaxHeight == null) {
return oldMaxHeight ?? newMaxHeight ?? _heights.values.min;
}

return lerpDouble(oldMaxHeight, newMaxHeight, page - page.floorToDouble())!;
}
Expand Down

0 comments on commit 763661e

Please sign in to comment.