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() {
  final cache = _cache.value;
  final collectedAt = cache.collectedAt;
  if (collectedAt != null &&
      DateTime.now().difference(collectedAt) < cacheDuration) {
    return Future.value(cache.data!);
  }

  return cache.inFlight ??= _safeCollect(cache).whenComplete(() {
    cache.inFlight = null;
  });
}