load method

Future<T?> load()

Implementation

Future<T?> load() async {
  _ensureHistoryLoaded();
  // ENH-94: a verified cache entry always wins over the bundled asset —
  // it only ever exists after a signature-verified fetch, so its mere
  // presence-and-validity already implies it's live-ops content strictly
  // newer in provenance than what was compiled into the app, regardless
  // of any timestamp on either side (the asset carries none at all).
  if (!_tryLoadFromCache()) {
    try {
      final raw = await _bundle.loadString(assetPath);
      final decoded = jsonDecode(raw);
      final validated = _validateSchema(decoded);
      if (validated != null) _current = fromJson(validated);
    } catch (_) {
      // No bundled asset (or invalid JSON/shape) → _current stays
      // whatever it was (null on first load).
    }
  }

  final fetch = fetchRemote;
  if (fetch != null) _refreshFuture = _refreshFromRemote(fetch);
  return _current;
}