feat: update RecipesViewNotifier and RecipesScreen to use maybeWhen for safer state handling
This commit is contained in:
@@ -13,8 +13,10 @@ class RecipesScreen extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final recipesAsync = ref.watch(recipesProvider);
|
||||
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 Stack(
|
||||
children: [
|
||||
@@ -75,7 +77,7 @@ class RecipesScreen extends ConsumerWidget {
|
||||
backgroundImage: NetworkImage(recipe.imageUrl!),
|
||||
)
|
||||
: const CircleAvatar(child: Icon(Icons.restaurant)),
|
||||
title: Text(recipe.name),
|
||||
title: Text(recipe.title),
|
||||
subtitle: Text(recipe.description ?? ''),
|
||||
onTap: () => context.push('/recipes/${recipe.id}'),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user