Skip to content

Commit 520bc46

Browse files
committed
feat(ads): add AdFeedItem class for native ads integration
- Create AdFeedItem class to wrap loaded native ad objects - Implement EquatableMixin for easy comparison - Add properties for unique identifier and native ad object - Enable seamless integration of ads into the application's feed structure
1 parent f36b005 commit 520bc46

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

lib/ads/models/ad_feed_item.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import 'package:core/core.dart';
2+
import 'package:equatable/equatable.dart';
3+
import 'package:google_mobile_ads/google_mobile_ads.dart';
4+
5+
/// {@template ad_feed_item}
6+
/// A [FeedItem] that wraps a loaded native ad object from an ad network SDK.
7+
///
8+
/// This class allows actual, displayable ad objects (like [NativeAd] from
9+
/// Google Mobile Ads) to be seamlessly integrated into the application's
10+
/// generic feed structure alongside other content types (e.g., [Headline]).
11+
/// {@endtemplate}
12+
class AdFeedItem extends FeedItem with EquatableMixin {
13+
/// {@macro ad_feed_item}
14+
const AdFeedItem({
15+
required this.id,
16+
required this.nativeAd,
17+
}) : super(type: 'ad_feed_item');
18+
19+
/// A unique identifier for this specific ad instance in the feed.
20+
///
21+
/// This is distinct from the ad unit ID and is used for tracking
22+
/// the ad within the feed.
23+
final String id;
24+
25+
/// The loaded native ad object from the ad network SDK.
26+
///
27+
/// This object contains the actual ad content and is ready for display.
28+
final NativeAd nativeAd;
29+
30+
@override
31+
List<Object?> get props => [id, nativeAd, type];
32+
}

0 commit comments

Comments
 (0)