Cart Provider Wiring
NotifierProviders for the cart feature
Overview
Two NotifierProviders are exported: cartControllerProvider (the local cart list) and cartSelectionProvider (the selected variantIds). The backend CartService is plain — instantiated where needed; not provider-wrapped today.
User Flow
- cartControllerProvider builds with currentCustomerIdProvider as a watched dependency.
- cartSelectionProvider builds with cartControllerProvider as a watched dependency.
- Consumers (CartScreen, CheckoutScreen, AddToCart buttons) ref.watch / ref.read these providers directly.
- CartService is constructed inline in CheckoutController and other consumers — no provider gate.
Cases & Edge Cases
- Adding a provider for CartService would let tests inject a mock — currently not done.
- Provider disposal is implicit — they live for the app lifetime since nothing else holds a parent scope.
Code References
- lib/src/features/shared/cart/controllers/cart_controller.dart:130 // cartControllerProvider
- lib/src/features/shared/cart/controllers/cart_selection_controller.dart:30 // cartSelectionProvider
API Calls
Empty — fill this in later. Open the manifest and add content here.
Notes
currentCustomerIdProvider lives in profile/personal_info_provider.dart — see the profile feature for its definition.