requestRefresh method

void requestRefresh()

Requests a refresh using Future.microtask.

  • Once a refresh has been requested but hasn't been performed yet, any subsequent requests will be ignored until a refresh is executed.
  • This method is useful to avoid unnecessary refreshes due consecutive state changes.

Implementation

void requestRefresh() {
  if (_requestRefresh != null) return;

  Future.microtask(() {
    var req = _requestRefresh;

    refresh();

    // if `refresh` didn't clear `_requestRefresh`:
    if (req != null && identical(req, _requestRefresh)) {
      _requestRefresh = null;
    }
  });
}