SellersNotifier
providers/sellers_provider.dart · Notifier<SellersState>
Overview
Owns seller fetching, paginated load, lazy-load-on-first-search, local filter, search history (load/add/remove/clear), and reset on screen close.
User Flow
- build() schedules Future.microtask(loadHistory) so the history strip appears before any fetch.
- search(query) updates searchQuery + filteredSellers locally; if the catalog is empty and query is non-empty, kicks off fetchSellers.
- fetchSellers POSTs /store/seller with offset/limit; appends to state.sellers on offset>0.
- fetchAllSellers loops fetchSellers until hasMoreData is false (used by Search-All-In-Map flow).
- Search history is persisted in LocalStorageService — addToHistory / removeFromHistory / clearHistory all reload via loadHistory.
Cases & Edge Cases
- Lazy fetch: the catalog is NOT fetched until the first non-empty search — saves a request on opening Search with no intent.
- Local filter is name+handle case-insensitive contains — no fuzzy matching; an exact handle match is not prioritized.
- fetchAllSellers has a safety check `if (currentOffset == previousOffset) break` to prevent infinite loops if the server returns 0 items but a non-zero count.
Code References
- lib/src/features/shared/search/providers/sellers_provider.dart:65 // SellersNotifier
- lib/src/features/shared/search/providers/sellers_provider.dart:104 // fetchSellers (paginated)
- lib/src/features/shared/search/providers/sellers_provider.dart:174 // search (lazy)
- lib/src/features/shared/search/providers/sellers_provider.dart:192 // _applyLocalFilter
- lib/src/features/shared/search/providers/sellers_provider.dart:202 // fetchAllSellers
API Calls
Empty — fill this in later. Open the manifest and add content here.
Notes
Debounce was removed (see commented `_debounce?.cancel()` in reset) — current implementation relies on the user to slow down keystrokes.