Before loading ads, have your app initialize the Mobile Ads SDK by calling EasyAds.instance.initialize() which initializes the SDK and returns a Future that finishes once initialization is complete (or after a 30-second timeout). This needs to be done only once, ideally right before running the app.
Ad is automatically loaded after being displayed or first time when you call initialize.
But on safe side, you can call this method. This will load both rewarded and interstitial ads.
If a particular ad is already loaded, it will not load it again.
EasyAds.instance.loadAd();
Show interstitial or rewarded ad
EasyAds.instance.showAd(AdUnitType.rewarded);
Show appOpen ad
EasyAds.instance.showAd(AdUnitType.appOpen)
Show Banner Ads
This is how you may show banner ad in widget-tree somewhere:
This package supports JIT (Just-in-Time) ad loading for Interstitial, App Open, and Rewarded ads.
You can show ads on demand, with callbacks for success, failure, and dismissal.
This ensures native ads are properly loaded and displayed within your UI.
Listening to the callbacks
Declare this object in the class
StreamSubscription? _streamSubscription;
We are showing InterstitialAd here and also checking if ad has been shown.
If true, we are canceling the subscribed callbacks, if any.
Then, we are listening to the Stream and accessing the particular event we need
if (EasyAds.instance.showInterstitialAd()) {
// Canceling the last callback subscribed
_streamSubscription?.cancel();
// Listening to the callback from showInterstitialAd()
_streamSubscription =
EasyAds.instance.onEvent.listen((event) {
if (event.adUnitType == AdUnitType.interstitial &&
event.type == AdEventType.adDismissed) {
_streamSubscription?.cancel();
goToNextScreen(countryList[index]);
}
});
}