@@ -5,9 +5,12 @@ import 'package:flutter/material.dart';
55import 'package:flutter_news_app_mobile_client_full_source_code/ads/ad_cache_service.dart' ;
66import 'package:flutter_news_app_mobile_client_full_source_code/ads/ad_service.dart' ;
77import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/ad_theme_style.dart' ;
8- import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/ad_feed_item .dart' ;
8+ import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/banner_ad .dart' ;
99import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/inline_ad.dart' ;
10- import 'package:flutter_news_app_mobile_client_full_source_code/ads/widgets/ad_feed_item_widget.dart' ;
10+ import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/native_ad.dart' ;
11+ import 'package:flutter_news_app_mobile_client_full_source_code/ads/widgets/admob_inline_ad_widget.dart' ;
12+ import 'package:flutter_news_app_mobile_client_full_source_code/ads/widgets/local_banner_ad_widget.dart' ;
13+ import 'package:flutter_news_app_mobile_client_full_source_code/ads/widgets/local_native_ad_widget.dart' ;
1114import 'package:flutter_news_app_mobile_client_full_source_code/ads/widgets/placeholder_ad_widget.dart' ;
1215import 'package:logging/logging.dart' ;
1316import 'package:ui_kit/ui_kit.dart' ;
@@ -210,12 +213,20 @@ class _InArticleAdLoaderWidgetState extends State<InArticleAdLoaderWidget> {
210213 } else if (_hasError || _loadedAd == null ) {
211214 return const PlaceholderAdWidget ();
212215 } else {
213- return AdFeedItemWidget (
214- adFeedItem: AdFeedItem (
215- id: widget.slotConfiguration.slotType.name,
216- inlineAd: _loadedAd! ,
217- ),
218- );
216+ // If an ad is successfully loaded, dispatch to the appropriate
217+ // provider-specific widget for rendering.
218+ switch (_loadedAd! .provider) {
219+ case AdPlatformType .admob:
220+ return AdmobInlineAdWidget (inlineAd: _loadedAd! );
221+ case AdPlatformType .local:
222+ if (_loadedAd is NativeAd && _loadedAd! .adObject is LocalNativeAd ) {
223+ return LocalNativeAdWidget (localNativeAd: _loadedAd! .adObject as LocalNativeAd );
224+ } else if (_loadedAd is BannerAd && _loadedAd! .adObject is LocalBannerAd ) {
225+ return LocalBannerAdWidget (localBannerAd: _loadedAd! .adObject as LocalBannerAd );
226+ }
227+ // Fallback for unsupported local ad types or errors
228+ return const PlaceholderAdWidget ();
229+ }
219230 }
220231 }
221232}
0 commit comments