refresh method

Future<void> refresh(
  1. AbstractListRefreshEvent event,
  2. Emitter<S> emit
)

Implementation

Future<void> refresh(AbstractListRefreshEvent event, Emitter<S> emit) async {
  if (state is AbstractListFilterablePaginatedState) {
    (state as AbstractListFilterablePaginatedState).searchModel.reset();
  }

  await onBeforeRefresh(event, emit);

  try {
    emit(await convertResultToStateAfterRefresh(await resolveData()));
  } catch (e) {
    await for (final result in resolveStreamData()) {
      emit(await convertResultToStateAfterRefresh(result));
      await onAfterRefresh(event, emit, result);
    }
  }
}