showNutritionPage static method
- required Product product,
- required bool isLoggedInMandatory,
- required BuildContext context,
Shows the nutrition page after loading the ordered nutrient list.
Implementation
static Future<void> showNutritionPage({
required Product product,
required bool isLoggedInMandatory,
required BuildContext context,
}) async {
if (!await ProductRefresher().checkIfLoggedIn(
context,
isLoggedInMandatory: isLoggedInMandatory,
)) {
return;
}
if (context.mounted) {
final OrderedNutrientsCache? cache = await OrderedNutrientsCache.getCache(
context,
product.productType,
);
if (context.mounted) {
if (cache == null) {
ScaffoldMessenger.of(context).showSnackBar(
SmoothFloatingSnackbar.error(
context: context,
text: AppLocalizations.of(context).nutrition_cache_loading_error,
),
);
return;
}
await Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) => NutritionPageLoaded(
product,
cache.orderedNutrients,
isLoggedInMandatory: isLoggedInMandatory,
),
),
);
}
}
}