RemoteContentPack<T>.withCache constructor

RemoteContentPack<T>.withCache({
  1. required String assetPath,
  2. required int schemaVersion,
  3. required T fromJson(
    1. Map<String, Object?> json
    ),
  4. required StorageService? storage,
  5. required String? cacheKey,
  6. Map<String, Object?> migrate(
    1. int fromVersion,
    2. Map<String, Object?> json
    )?,
  7. String? contentSecret,
  8. Future<Map<String, Object?>> fetchRemote()?,
  9. Duration? maxCacheAge,
  10. AssetBundle? bundle,
})

ENH-94: same signed/typed content pack with a durable verified cache. Kept as a NAMED constructor (instead of changing RemoteContentPack's existing signature by adding optional params) so every pre-existing consumer remains 100% API-gate compatible — additive only, no major version bump/BREAKING changelog required.

Implementation

RemoteContentPack.withCache({
  required this.assetPath,
  required this.schemaVersion,
  required this.fromJson,
  required this.storage,
  required this.cacheKey,
  this.migrate,
  this.contentSecret,
  this.fetchRemote,
  this.maxCacheAge,
  AssetBundle? bundle,
}) : historyCapacity = null,
     contentVersionResolver = null,
     _bundle = bundle ?? rootBundle {
  if (cacheKey == null || cacheKey!.isEmpty) {
    throw ArgumentError.value(cacheKey, 'cacheKey', 'must not be empty');
  }
}