From 367218702bec05df4d4cea707f1f83be0a19f798 Mon Sep 17 00:00:00 2001 From: FaizHashmi Date: Mon, 19 Oct 2026 16:50:15 +0300 Subject: [PATCH] Filters Fix --- lib/ui/landing/dashboard_screen_for_dependet.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ui/landing/dashboard_screen_for_dependet.dart b/lib/ui/landing/dashboard_screen_for_dependet.dart index 662b6c2..0c32f09 100644 --- a/lib/ui/landing/dashboard_screen_for_dependet.dart +++ b/lib/ui/landing/dashboard_screen_for_dependet.dart @@ -335,7 +335,11 @@ class _DashboardScreenForDependetState extends State try { int nextPage = currentPage + 1; - String catParam = (currentCategoryId == "all" || currentCategoryId == "0") ? "" : currentCategoryId; + // Must match fetchOffers's category resolution exactly (including the selected + // subcategory, if any) - otherwise pagination silently switches filters mid-scroll, + // fetching an overlapping result set under the same page number and duplicating items. + String effectiveCategoryId = _selectedSubcategoryId ?? currentCategoryId; + String catParam = (effectiveCategoryId == "all" || effectiveCategoryId == "0") ? "" : effectiveCategoryId; String? offerTypeParam = OffersAndDiscountsApiClient.mapOfferTypeFilter(selectedTypeFilter); String? queryParam = searchQuery.trim().isNotEmpty ? searchQuery.trim() : null; int? radiusParam = _radiusFromFilterDistance(_filterDistance); @@ -378,7 +382,8 @@ class _DashboardScreenForDependetState extends State } Future _onRefresh() async { - await Future.wait(>[fetchCategories(), fetchOffers(categoryId: currentCategoryId.isEmpty ? "all" : currentCategoryId, query: _searchController.text)]); + String effectiveCategoryId = _selectedSubcategoryId ?? (currentCategoryId.isEmpty ? "all" : currentCategoryId); + await Future.wait(>[fetchCategories(), fetchOffers(categoryId: effectiveCategoryId, query: _searchController.text)]); } // '5km'/'10km'/'25km' -> 5/10/25 for WP_Radius; 'any' -> null (omit the param - no distance cap).