getCache method Null safety
- dynamic context
Returns a database/downloaded cache, or null if it failed.
Implementation
static Future<OrderedNutrientsCache?> getCache(
final BuildContext context,
) async {
final LocalDatabase localDatabase = context.read<LocalDatabase>();
final OrderedNutrientsCache cache = OrderedNutrientsCache._(localDatabase);
cache._orderedNutrients = await cache._get() ??
await LoadingDialog.run<OrderedNutrients>(
context: context,
future: cache._download(),
);
if (cache._orderedNutrients == null) {
await LoadingDialog.error(context: context);
return null;
}
return cache;
}