arch-atlas

Search History (SharedPreferences)

core/services/local_storage.dart · sellerSearchHistory

data

Overview

Persistent recent-search list keyed globally (not per-user). Up to N entries; new entries push the oldest off the end. Used to render the suggestions strip before the user types.

User Flow

  1. getSellerSearchHistory reads a JSON array.
  2. addSellerToSearchHistory dedupes by id and prepends.
  3. removeSellerFromSearchHistory drops one entry; clearSellerSearchHistory wipes all.

Cases & Edge Cases

  • History is shared across customer/seller roles on the same device — switching role keeps the same recent list.
  • JSON-decode error resets to empty (corrupt local state recovers silently).

Code References

  • lib/src/core/services/local_storage.dart // getSellerSearchHistory / addSellerToSearchHistory / removeSellerFromSearchHistory / clearSellerSearchHistory

API Calls

Empty — fill this in later. Open the manifest and add content here.

Notes

If we move history to a per-user key (like the cart does), make sure to migrate existing entries to avoid surprising users. Local storage contracts (SharedPreferences): • getSellerSearchHistory() — read 'seller_search_history' → List<Map> → List<Seller> — screen: lib/src/features/shared/search/search.dart (history strip) • addSellerToSearchHistory(seller) — dedupe by id + prepend — screen: search.dart (on result tap) • removeSellerFromSearchHistory(id) — screen: search.dart (long-press dismiss) • clearSellerSearchHistory() — screen: search.dart (Clear all)