@@ -34,7 +34,6 @@ class InArticleAdLoaderWidget extends StatefulWidget {
3434 /// {@macro in_article_ad_loader_widget}
3535 const InArticleAdLoaderWidget ({
3636 required this .slotConfiguration,
37- required this .adService,
3837 required this .adThemeStyle,
3938 required this .adConfig,
4039 super .key,
@@ -43,9 +42,6 @@ class InArticleAdLoaderWidget extends StatefulWidget {
4342 /// The configuration for this specific in-article ad slot.
4443 final InArticleAdSlotConfiguration slotConfiguration;
4544
46- /// The service responsible for loading ads from ad networks.
47- final AdService adService;
48-
4945 /// The current theme style for ads, used during ad loading.
5046 final AdThemeStyle adThemeStyle;
5147
@@ -63,13 +59,15 @@ class _InArticleAdLoaderWidgetState extends State<InArticleAdLoaderWidget> {
6359 bool _hasError = false ;
6460 final Logger _logger = Logger ('InArticleAdLoaderWidget' );
6561 late final InlineAdCacheService _adCacheService;
62+ late final AdService _adService; // AdService will be accessed via _adCacheService
6663
6764 Completer <void >? _loadAdCompleter;
6865
6966 @override
7067 void initState () {
7168 super .initState ();
72- _adCacheService = InlineAdCacheService (adService: widget.adService);
69+ _adCacheService = context.read <InlineAdCacheService >();
70+ _adService = context.read <AdService >();
7371 _loadAd ();
7472 }
7573
@@ -158,7 +156,7 @@ class _InArticleAdLoaderWidgetState extends State<InArticleAdLoaderWidget> {
158156 );
159157 try {
160158 // Call AdService.getInArticleAd with the full AdConfig.
161- final loadedAd = await widget.adService .getInArticleAd (
159+ final loadedAd = await _adService .getInArticleAd (
162160 adConfig: widget.adConfig,
163161 adThemeStyle: widget.adThemeStyle,
164162 );
@@ -235,12 +233,14 @@ class _InArticleAdLoaderWidgetState extends State<InArticleAdLoaderWidget> {
235233 padding: const EdgeInsets .symmetric (
236234 horizontal: AppSpacing .paddingMedium,
237235 ),
238- child: Text (
239- l10n.adInfoPlaceholderText,
240- style: theme.textTheme.labelSmall? .copyWith (
241- color: theme.colorScheme.onSurfaceVariant,
236+ child: Center (
237+ child: Text (
238+ l10n.adInfoPlaceholderText,
239+ style: theme.textTheme.labelSmall? .copyWith (
240+ color: theme.colorScheme.onSurfaceVariant,
241+ ),
242+ textAlign: TextAlign .center,
242243 ),
243- textAlign: TextAlign .center,
244244 ),
245245 ),
246246 ),
0 commit comments