fix: eliminate pull-to-refresh flicker by holding stale data during re-fetch
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user