Files
recipe-app/flutter/lib/features/pantry/data/pantry_providers.dart
T
Nils-Johan Gynther 68476142c1
Test Suite / test (24.15.0) (push) Has been cancelled
refactor: Remove PantryProduct class and simplify category resolution in PantryScreen
2026-05-11 20:01:00 +02:00

20 lines
665 B
Dart

import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/api/api_providers.dart';
import '../../../core/api/guarded_api_call.dart';
import '../../auth/data/auth_providers.dart';
import '../domain/pantry_item.dart';
import 'pantry_repository.dart';
final pantryRepositoryProvider = Provider<PantryRepository>((ref) {
return PantryRepository(ref.watch(apiClientProvider));
});
final pantryProvider = FutureProvider<List<PantryItem>>((ref) async {
final token = await ref.watch(authStateProvider.future);
return guardedApiCall(
ref,
() => ref.read(pantryRepositoryProvider).fetchPantry(token: token),
);
});