getCachedDomains method
Cached projection of `MyCurriculumDomains` — id/name/slug only, capped
to keep the blob tiny. Reads return an empty list if missing or stale.
Implementation
Future<List<CachedDomain>> getCachedDomains() async {
final p = await _prefs();
final raw = p.getString(_homeDomainsKey);
if (raw == null) return const [];
try {
final json = jsonDecode(raw) as Map<String, dynamic>;
if (_isStale(json['savedAt'] as String?)) return const [];
final items = json['value'] as List<dynamic>;
return items
.map((e) => CachedDomain.fromJson((e as Map).cast<String, dynamic>()))
.toList(growable: false);
} catch (_) {
return const [];
}
}