@@ -49,12 +49,10 @@ class _CountryFilterPageState extends State<CountryFilterPage> {
4949 /// `HeadlinesFilterPage` . This ensures the checkboxes reflect the state
5050 /// from the main filter page when this page loads.
5151 late Set <Country > _pageSelectedCountries;
52- late final CountriesFilterBloc _countriesFilterBloc;
5352
5453 @override
5554 void initState () {
5655 super .initState ();
57- _countriesFilterBloc = context.read <CountriesFilterBloc >();
5856
5957 // Initialization needs to happen after the first frame to safely access
6058 // GoRouterState.of(context).
@@ -70,11 +68,6 @@ class _CountryFilterPageState extends State<CountryFilterPage> {
7068 // This ensures the checkboxes on this page are initially checked
7169 // correctly based on the selections made previously.
7270 _pageSelectedCountries = Set .from (initialSelection ?? []);
73-
74- // 3. Trigger the page-specific BLoC (CountriesFilterBloc) to start
75- // fetching the list of *all available* countries that the user can
76- // potentially select from, using the specified usage filter.
77- _countriesFilterBloc.add (CountriesFilterRequested (usage: widget.filter));
7871 });
7972 }
8073
@@ -101,15 +94,18 @@ class _CountryFilterPageState extends State<CountryFilterPage> {
10194 builder: (context, appState) {
10295 final followedCountries =
10396 appState.userContentPreferences? .followedCountries ?? [];
104- final isFollowedFilterActive = followedCountries.isNotEmpty &&
97+ final isFollowedFilterActive =
98+ followedCountries.isNotEmpty &&
10599 _pageSelectedCountries.length == followedCountries.length &&
106100 _pageSelectedCountries.containsAll (followedCountries);
107101
108102 return IconButton (
109103 icon: isFollowedFilterActive
110104 ? const Icon (Icons .favorite)
111105 : const Icon (Icons .favorite_border),
112- color: isFollowedFilterActive ? theme.colorScheme.primary : null ,
106+ color: isFollowedFilterActive
107+ ? theme.colorScheme.primary
108+ : null ,
113109 tooltip: l10n.headlinesFeedFilterApplyFollowedLabel,
114110 onPressed: () {
115111 setState (() {
@@ -161,9 +157,8 @@ class _CountryFilterPageState extends State<CountryFilterPage> {
161157 if (state.status == CountriesFilterStatus .failure &&
162158 state.countries.isEmpty) {
163159 return FailureStateWidget (
164- exception:
165- state.error ?? const UnknownException ('Unknown error' ),
166- onRetry: () => _countriesFilterBloc.add (
160+ exception: state.error ?? const UnknownException ('Unknown error' ),
161+ onRetry: () => context.read <CountriesFilterBloc >().add (
167162 CountriesFilterRequested (usage: widget.filter),
168163 ),
169164 );
@@ -196,9 +191,7 @@ class _CountryFilterPageState extends State<CountryFilterPage> {
196191 height: AppSpacing .lg + AppSpacing .sm,
197192 child: ClipRRect (
198193 // Clip the image for rounded corners if desired
199- borderRadius: BorderRadius .circular (
200- AppSpacing .xs / 2 ,
201- ),
194+ borderRadius: BorderRadius .circular (AppSpacing .xs / 2 ),
202195 child: Image .network (
203196 country.flagUrl,
204197 fit: BoxFit .cover,
@@ -212,8 +205,7 @@ class _CountryFilterPageState extends State<CountryFilterPage> {
212205 return Center (
213206 child: CircularProgressIndicator (
214207 strokeWidth: 2 ,
215- value:
216- loadingProgress.expectedTotalBytes != null
208+ value: loadingProgress.expectedTotalBytes != null
217209 ? loadingProgress.cumulativeBytesLoaded /
218210 loadingProgress.expectedTotalBytes!
219211 : null ,
0 commit comments