homeFirstPaintCache function

  1. @Riverpod(keepAlive: true)
Future<HomeFirstPaintCacheData> homeFirstPaintCache(
  1. Ref<Object?> ref
)

Reads the home first-paint cache once and keeps the values alive for the session. Read with valueOrNull to get a fallback value or null.

Implementation

@Riverpod(keepAlive: true)
Future<HomeFirstPaintCacheData> homeFirstPaintCache(Ref ref) async {
  final ds = ref.watch(userPrefsDatasourceProvider);
  final results = await Future.wait([
    ds.getCachedStreak(),
    ds.getCachedDueCount(),
    ds.getCachedDomains(),
  ]);
  return HomeFirstPaintCacheData(
    streak: results[0] as int?,
    dueCount: results[1] as int?,
    domains: results[2] as List<CachedDomain>,
  );
}