feat: update RecipesViewNotifier and RecipesScreen to use maybeWhen for safer state handling

This commit is contained in:
Nils-Johan Gynther
2026-04-25 07:12:36 +02:00
parent ba4e931f5c
commit 46de546f9f
3 changed files with 18 additions and 8 deletions
+5 -3
View File
@@ -105,11 +105,13 @@ class AppShell extends ConsumerWidget {
appBar: AppBar(
title: Text(selectedDestination.title),
actions: [
if (isRecipesRoute) ...existing code...
if (isRecipesRoute)
Consumer(
builder: (context, ref, child) {
final view = ref.watch(recipesViewProvider).valueOrNull ??
(mode: RecipesViewMode.grid, columns: 2);
final view = ref.watch(recipesViewProvider).maybeWhen(
data: (v) => v,
orElse: () => (mode: RecipesViewMode.grid, columns: 2),
);
return Row(
mainAxisSize: MainAxisSize.min,
children: [