Skip to content

Commit 4aef397

Browse files
committed
refactor(entity_details): inject InlineAdCacheService and remove AdService dependencies
- Inject InlineAdCacheService into EntityDetailsBloc for ad caching management - Remove InlineAdCacheService instantiation within EntityDetailsBloc - Remove AdService import from entity_details_page.dart - Remove adService parameter from FeedAdLoaderWidget
1 parent 706cd82 commit 4aef397

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/entity_details/bloc/entity_details_bloc.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
2424
required AccountBloc accountBloc,
2525
required AppBloc appBloc,
2626
required FeedDecoratorService feedDecoratorService,
27+
required InlineAdCacheService inlineAdCacheService,
2728
}) : _headlinesRepository = headlinesRepository,
2829
_topicRepository = topicRepository,
2930
_sourceRepository = sourceRepository,
3031
_countryRepository = countryRepository,
3132
_accountBloc = accountBloc,
3233
_appBloc = appBloc,
3334
_feedDecoratorService = feedDecoratorService,
35+
_inlineAdCacheService = inlineAdCacheService,
3436
super(const EntityDetailsState()) {
3537
on<EntityDetailsLoadRequested>(_onEntityDetailsLoadRequested);
3638
on<EntityDetailsToggleFollowRequested>(
@@ -58,6 +60,7 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
5860
final AccountBloc _accountBloc;
5961
final AppBloc _appBloc;
6062
final FeedDecoratorService _feedDecoratorService;
63+
final InlineAdCacheService _inlineAdCacheService;
6164
late final StreamSubscription<AccountState> _accountBlocSubscription;
6265

6366
static const _headlinesLimit = 10;
@@ -68,7 +71,7 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
6871
) async {
6972
// When loading a new entity's details, clear any previously cached ads
7073
// to ensure a fresh set of ads is displayed for the new content.
71-
InlineAdCacheService().clearAllAds();
74+
_inlineAdCacheService.clearAllAds();
7275
emit(
7376
state.copyWith(status: EntityDetailsStatus.loading, clearEntity: true),
7477
);

lib/entity_details/view/entity_details_page.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import 'package:core/core.dart';
44
import 'package:flutter/material.dart';
55
import 'package:flutter_bloc/flutter_bloc.dart';
6-
import 'package:flutter_news_app_mobile_client_full_source_code/ads/ad_service.dart';
76
import 'package:flutter_news_app_mobile_client_full_source_code/ads/interstitial_ad_manager.dart';
87
import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/ad_placeholder.dart';
98
import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/ad_theme_style.dart';
@@ -369,7 +368,6 @@ class _EntityDetailsViewState extends State<EntityDetailsView> {
369368

370369
return FeedAdLoaderWidget(
371370
adPlaceholder: item,
372-
adService: context.read<AdService>(),
373371
adThemeStyle: AdThemeStyle.fromTheme(
374372
Theme.of(context),
375373
),

0 commit comments

Comments
 (0)