@@ -36,10 +36,6 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
3636 _onAppFontSizeChanged,
3737 transformer: sequential (),
3838 );
39- on < SettingsHeadlineImageStyleChanged > (
40- _onHeadlineImageStyleChanged,
41- transformer: sequential (),
42- );
4339 on < SettingsAppFontTypeChanged > (
4440 _onAppFontTypeChanged,
4541 transformer: sequential (),
@@ -168,9 +164,11 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
168164 ),
169165 );
170166 emit (state.copyWith (userAppSettings: updatedSettings, clearError: true ));
171- await _persistSettings (updatedSettings, emit);
172- // Clear ad cache when theme accent changes to ensure new ads are styled correctly.
167+ // When the theme's accent color changes, ads must be reloaded to reflect
168+ // the new styling. Clearing the cache ensures that any visible or
169+ // soon-to-be-visible ads are fetched again with the updated theme.
173170 AdCacheService ().clearAllAds ();
171+ await _persistSettings (updatedSettings, emit);
174172 }
175173
176174 Future <void > _onAppFontSizeChanged (
@@ -188,24 +186,6 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
188186 await _persistSettings (updatedSettings, emit);
189187 }
190188
191- Future <void > _onHeadlineImageStyleChanged (
192- SettingsHeadlineImageStyleChanged event,
193- Emitter <SettingsState > emit,
194- ) async {
195- if (state.userAppSettings == null ) return ;
196-
197- final updatedSettings = state.userAppSettings! .copyWith (
198- feedPreferences: state.userAppSettings! .feedPreferences.copyWith (
199- headlineImageStyle: event.imageStyle,
200- ),
201- );
202- emit (state.copyWith (userAppSettings: updatedSettings, clearError: true ));
203- await _persistSettings (updatedSettings, emit);
204- // Clear ad cache when headline image style changes to ensure new ads are
205- // loaded with the correct template type (small/medium).
206- AdCacheService ().clearAllAds ();
207- }
208-
209189 Future <void > _onAppFontTypeChanged (
210190 SettingsAppFontTypeChanged event,
211191 Emitter <SettingsState > emit,
@@ -248,6 +228,11 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
248228 ),
249229 );
250230 emit (state.copyWith (userAppSettings: updatedSettings, clearError: true ));
231+ // The headline image style directly influences which native ad template
232+ // (small or medium) is requested. To ensure the correct ad format is
233+ // displayed, the cache must be cleared, forcing a new ad load with the
234+ // appropriate template.
235+ AdCacheService ().clearAllAds ();
251236 await _persistSettings (updatedSettings, emit);
252237 }
253238
0 commit comments