Skip to content

Commit f36b005

Browse files
committed
feat(ads): define AdProvider abstract class
- Create AdProvider as an abstract class to define the interface for ad network providers - Add initialize() method for ad network SDK setup - Add loadNativeAd() method for loading native ads - Include documentation comments for better code understanding
1 parent 7d44d9e commit f36b005

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lib/ads/ad_provider.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import 'package:google_mobile_ads/google_mobile_ads.dart';
2+
3+
/// {@template ad_provider}
4+
/// An abstract class defining the interface for any ad network provider.
5+
///
6+
/// This abstraction allows the application to integrate with different
7+
/// ad networks (e.g., AdMob, Meta Audience Network) through a common API,
8+
/// promoting extensibility and decoupling.
9+
/// {@endtemplate}
10+
abstract class AdProvider {
11+
/// {@macro ad_provider}
12+
const AdProvider();
13+
14+
/// Initializes the ad network SDK.
15+
///
16+
/// This method should be called once at application startup.
17+
/// It handles any necessary setup for the specific ad network.
18+
Future<void> initialize();
19+
20+
/// Loads a native ad.
21+
///
22+
/// Returns a [NativeAd] object if an ad is successfully loaded,
23+
/// otherwise returns `null`.
24+
Future<NativeAd?> loadNativeAd();
25+
26+
// Future methods for other ad types (e.g., interstitial, banner)
27+
// can be added here as needed in the future.
28+
}

0 commit comments

Comments
 (0)