state_management
State Management (Riverpod)
Overview The app uses flutter_riverpod to expose data as providers and to orchestrate UI state.
Key Providers
- component_provider.dart
- componentRepositoryProvider: Provides ComponentRepository implementation
- componentsProvider: FutureProvider> – loads local components
- componentSearchProvider: FutureProvider.family – (used earlier for remote search; local Components now filter in-memory)
- digikey_component_provider.dart
- digikeyComponentRepositoryProvider: Provides repository for DigiKey operations
- digikeyComponentsProvider: Loads list if needed (not shown initially in DigiKey page)
-
digikeyComponentSearchProvider: Executes search against DigiKey endpoint
-
category_provider.dart
-
Provides full category structure for filtering and browsing
-
digikey_token_provider.dart
- Exposes DigiKey token manager to acquire/refresh OAuth tokens when needed
Invalidation Patterns - After adding/editing components, UI calls ref.invalidate(componentsProvider) to refresh the local list. - On DigiKey add, UI invalidates both digikeyComponentsProvider and componentsProvider to reflect new items locally.
UI Binding - Screens call ref.watch(...) to subscribe to providers and render AsyncValue.when data/loading/error variants. - For dialogs or one-off reads, ref.read(...) is used.