Skip to content

Commit 24c982a

Browse files
committed
perf(headlines-feed): optimize followed filter activation logic
- Convert followedCountries list to a set for more efficient lookup - Simplify the logic for checking if all selected countries are followed - Improve performance and readability of the followed filter activation check
1 parent 9e56060 commit 24c982a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/headlines-feed/view/country_filter_page.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,13 @@ class _CountryFilterPageState extends State<CountryFilterPage> {
9191
BlocBuilder<CountriesFilterBloc, CountriesFilterState>(
9292
builder: (context, state) {
9393
// Determine if the "Apply My Followed" icon should be filled
94+
final followedCountriesSet = state.followedCountries.toSet();
9495
final isFollowedFilterActive =
95-
state.followedCountries.isNotEmpty &&
96+
followedCountriesSet.isNotEmpty &&
9697
_pageSelectedCountries.length ==
97-
state.followedCountries.length &&
98-
_pageSelectedCountries.every(
99-
state.followedCountries.contains,
100-
);
101-
98+
followedCountriesSet.length &&
99+
_pageSelectedCountries.containsAll(followedCountriesSet);
100+
102101
return IconButton(
103102
icon: isFollowedFilterActive
104103
? const Icon(Icons.favorite)

0 commit comments

Comments
 (0)