getData method

  1. @override
Future<Map<String, dynamic>> getData()
override

Collects context data. Implementations must never throw; if an internal error occurs, return an empty map instead.

Implementation

@override
Future<Map<String, dynamic>> getData() {
  if (_cacheValid) {
    // Non-null by contract when _cacheValid is true.
    return Future.value(_cacheCell.value!);
  }

  final inFlight = _inFlightCell.value;
  if (inFlight != null) return inFlight;

  final future = _safeCollect();
  _inFlightCell.value = future;
  return future.whenComplete(() => _inFlightCell.value = null);
}