Skip to content

Commit 06c8f36

Browse files
committed
refactor(ads): update ad_loader_widget to use inline_ad
- Replace NativeAd with InlineAd for better naming consistency - Update ad retrieval and caching logic to use inlineAd instead of nativeAd - Make necessary import and variable name changes
1 parent ed48399 commit 06c8f36

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/ads/widgets/ad_loader_widget.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flutter_news_app_mobile_client_full_source_code/ads/ad_service.d
77
import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/ad_feed_item.dart';
88
import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/ad_placeholder.dart';
99
import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/ad_theme_style.dart';
10-
import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/native_ad.dart';
10+
import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/inline_ad.dart'; // Import InlineAd
1111
import 'package:flutter_news_app_mobile_client_full_source_code/ads/widgets/ad_feed_item_widget.dart';
1212
import 'package:flutter_news_app_mobile_client_full_source_code/ads/widgets/placeholder_ad_widget.dart';
1313
import 'package:logging/logging.dart';
@@ -17,7 +17,7 @@ import 'package:ui_kit/ui_kit.dart';
1717
/// A self-contained widget responsible for loading and displaying an inline ad.
1818
///
1919
/// This widget handles the entire lifecycle of a single ad slot in the feed.
20-
/// It attempts to retrieve a cached [NativeAd] first. If no ad is cached,
20+
/// It attempts to retrieve a cached [InlineAd] first. If no ad is cached,
2121
/// it requests a new one from the [AdService] using `getInlineAd` and stores
2222
/// it in the cache upon success. It manages its own loading and error states.
2323
///
@@ -32,7 +32,7 @@ class AdLoaderWidget extends StatefulWidget {
3232
required this.adPlaceholder,
3333
required this.adService,
3434
required this.adThemeStyle,
35-
required this.adConfig, // Now requires the full AdConfig
35+
required this.adConfig,
3636
super.key,
3737
});
3838

@@ -53,7 +53,7 @@ class AdLoaderWidget extends StatefulWidget {
5353
}
5454

5555
class _AdLoaderWidgetState extends State<AdLoaderWidget> {
56-
NativeAd? _loadedAd;
56+
InlineAd? _loadedAd; // Changed to InlineAd
5757
bool _isLoading = true;
5858
bool _hasError = false;
5959
final Logger _logger = Logger('AdLoaderWidget');
@@ -122,7 +122,7 @@ class _AdLoaderWidgetState extends State<AdLoaderWidget> {
122122

123123
/// Loads the inline ad for this slot.
124124
///
125-
/// This method first checks the [AdCacheService] for a pre-loaded [NativeAd].
125+
/// This method first checks the [AdCacheService] for a pre-loaded [InlineAd].
126126
/// If found, it uses the cached ad. Otherwise, it requests a new inline ad
127127
/// from the [AdService] using `getInlineAd` and stores it in the cache
128128
/// upon success.
@@ -194,11 +194,11 @@ class _AdLoaderWidgetState extends State<AdLoaderWidget> {
194194
'New ad loaded for placeholder ID: ${widget.adPlaceholder.id}',
195195
);
196196
// Store the newly loaded ad in the cache.
197-
_adCacheService.setAd(widget.adPlaceholder.id, adFeedItem.nativeAd);
197+
_adCacheService.setAd(widget.adPlaceholder.id, adFeedItem.inlineAd); // Use inlineAd
198198
// Ensure the widget is still mounted before calling setState.
199199
if (!mounted) return;
200200
setState(() {
201-
_loadedAd = adFeedItem.nativeAd;
201+
_loadedAd = adFeedItem.inlineAd; // Use inlineAd
202202
_isLoading = false;
203203
});
204204
// Complete the completer only if it hasn't been completed already.
@@ -269,7 +269,7 @@ class _AdLoaderWidgetState extends State<AdLoaderWidget> {
269269
return AdFeedItemWidget(
270270
adFeedItem: AdFeedItem(
271271
id: widget.adPlaceholder.id,
272-
nativeAd: _loadedAd!,
272+
inlineAd: _loadedAd!, // Use inlineAd
273273
),
274274
);
275275
}

0 commit comments

Comments
 (0)