fix: eliminate pull-to-refresh flicker by holding stale data during re-fetch

This commit is contained in:
2026-04-08 14:39:50 -04:00
parent 6c29b685e8
commit 3e888b6458
12 changed files with 70 additions and 14 deletions
+11
View File
@@ -56,6 +56,17 @@ class CalendarNotifier extends AsyncNotifier<CalendarState> {
);
}
/// Re-fetch events for the current range without clearing state (no flicker).
Future<void> refresh() async {
final current = state.value;
if (current == null) return;
final events = await ref.read(eventsApiProvider).getEvents(
current.loadedRange.start,
current.loadedRange.end,
);
state = AsyncData(current.copyWith(eventsByDay: _groupByDay(events)));
}
/// Synchronously updates selectedDay and focusedMonth. No API call.
void selectDay(DateTime day) {
final current = state.value;