refresh method

Future<void> refresh()

Calls the action. If it is currently running, will queue the action to run again when it's done.

Implementation

Future<void> refresh() async {
  if (isRefreshing) {
    performRefreshAfter = true;
    return;
  }

  isRefreshing = true;
  await action();
  isRefreshing = false;
  if (performRefreshAfter) {
    performRefreshAfter = false;
    unawaited(refresh());
  }
}