|
| 1 | +import 'package:equatable/equatable.dart'; |
| 2 | +import 'package:flutter/foundation.dart'; |
| 3 | + |
| 4 | +/// {@template native_ad} |
| 5 | +/// A generic, provider-agnostic model representing a native advertisement. |
| 6 | +/// |
| 7 | +/// This model decouples the application's core logic from specific ad network |
| 8 | +/// SDKs (e.g., Google Mobile Ads). It contains common fields found in native |
| 9 | +/// ads and holds a reference to the original, SDK-specific ad object for |
| 10 | +/// rendering purposes. |
| 11 | +/// {@endtemplate} |
| 12 | +@immutable |
| 13 | +class NativeAd extends Equatable { |
| 14 | + /// {@macro native_ad} |
| 15 | + const NativeAd({ |
| 16 | + required this.id, |
| 17 | + required this.headline, |
| 18 | + required this.body, |
| 19 | + required this.callToAction, |
| 20 | + this.iconUrl, |
| 21 | + this.imageUrl, |
| 22 | + this.advertiser, |
| 23 | + this.starRating, |
| 24 | + this.store, |
| 25 | + this.price, |
| 26 | + required this.adObject, |
| 27 | + }); |
| 28 | + |
| 29 | + /// A unique identifier for this specific native ad instance. |
| 30 | + final String id; |
| 31 | + |
| 32 | + /// The main headline or title of the advertisement. |
| 33 | + final String headline; |
| 34 | + |
| 35 | + /// The main body text or description of the advertisement. |
| 36 | + final String body; |
| 37 | + |
| 38 | + /// The text for the call-to-action button (e.g., "Install", "Learn More"). |
| 39 | + final String callToAction; |
| 40 | + |
| 41 | + /// The URL of the ad's icon image (e.g., app icon). |
| 42 | + final String? iconUrl; |
| 43 | + |
| 44 | + /// The URL of the main image asset for the ad. |
| 45 | + final String? imageUrl; |
| 46 | + |
| 47 | + /// The name of the advertiser or sponsor. |
| 48 | + final String? advertiser; |
| 49 | + |
| 50 | + /// The star rating for the advertised app (typically 1.0 to 5.0). |
| 51 | + final double? starRating; |
| 52 | + |
| 53 | + /// The name of the app store (e.g., "Google Play", "App Store"). |
| 54 | + final String? store; |
| 55 | + |
| 56 | + /// The price of the advertised app or product. |
| 57 | + final String? price; |
| 58 | + |
| 59 | + /// The original, SDK-specific ad object. |
| 60 | + /// |
| 61 | + /// This object is passed directly to the ad network's UI widget for rendering. |
| 62 | + /// It should be cast back to its specific type (e.g., `google_mobile_ads.NativeAd`) |
| 63 | + /// only within the dedicated ad rendering widget for that provider. |
| 64 | + final Object adObject; |
| 65 | + |
| 66 | + @override |
| 67 | + List<Object?> get props => [ |
| 68 | + id, |
| 69 | + headline, |
| 70 | + body, |
| 71 | + callToAction, |
| 72 | + iconUrl, |
| 73 | + imageUrl, |
| 74 | + advertiser, |
| 75 | + starRating, |
| 76 | + store, |
| 77 | + price, |
| 78 | + adObject, |
| 79 | + ]; |
| 80 | +} |
0 commit comments