admob_easy
Simplify your Flutter app's integration with Google AdMob for effortless monetization.
matifdeveloper/admob_easy open-source repository details.
{"sdk":"flutter"}^6.0.0^1.0.1^7.0.0^3.0.0{"sdk":"flutter"}^6.0.0English project snapshot. Visit GitHub for the latest content.
This documentation guides integrating ads into a Flutter application using the provided helper classes.
AdMob Easy automatically handles the User Messaging Platform (UMP) for you, ensuring compliance with privacy regulations.
<manifest>
...
<application>
...
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
</application>
</manifest>
...
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
...
To enable ad support, initialize AdmobEasy in the Splash Screen by providing the necessary ad unit IDs and test devices:
AdmobEasy.instance.initialize(
androidRewardedAdID: 'ca-app-pub-3940256099942544/5224354917',
androidInitAdID: 'ca-app-pub-3940256099942544/1033173712',
androidBannerAdID: 'ca-app-pub-3940256099942544/6300978111',
androidAppOpenAdID: 'ca-app-pub-3940256099942544/9257395921',
testDevices: ['543E082C0B43E6BF17AF6D4F72541F51'],
);
Use the provided methods to load ads:
AdmobEasy.instance.createRewardedAd(context); // Load rewarded ad
AdmobEasy.instance.createInterstitialAd(context); // Load Interstitial ad
AdmobEasy.instance.loadAppOpenAd(); // Load App Open Ad (shows automatically after load)
Once ads are loaded, show them using:
AdmobEasy.instance.showRewardedAd(context);
AdmobEasy.instance.showInterstitialAd(context);
Native ads are now handled via methods mixed directly into AdmobEasy.
You can preload, show, and dispose native ads with full control.
AdmobEasy.instance.loadNativeAd(
templateType: TemplateType.medium,
minWidth: 320,
minHeight: 90,
maxWidth: 400,
maxHeight: 200,
adID: "ca-app-pub-3940256099942544/2247696110", // optional custom ID
onAdClicked: (ad) => print("Ad Clicked"),
onAdImpression: (ad) => print("Ad Impression Logged"),
onAdClosed: (ad) => print("Ad Closed"),
onAdOpened: (ad) => print("Ad Opened"),
onAdWillDismissScreen: (ad) => print("Ad will dismiss screen"),
onPaidEvent: (ad, value, precision, currencyCode) {
print("Paid event: $value $currencyCode (precision: $precision)");
},
);
Once preloaded, show it anywhere in the widget tree:
class NativeAdScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Native Ad Example')),
body: Center(
child: AdmobEasy.instance.showNativeAd(
minWidth: 320,
minHeight: 90,
maxWidth: 400,
maxHeight: 200,
),
),
);
}
}
When you no longer need the preloaded ad:
@override
void dispose() {
AdmobEasy.instance.disposeNative();
super.dispose();
}
adID → Custom AdMob Unit ID (if null, defaults to AdmobEasy.instance.nativeAdID).templateType → Choose between TemplateType.small or TemplateType.medium.minWidth, minHeight, maxWidth, maxHeight → Controls the size of the ad container.onAdClicked → Callback when the ad is clicked.onAdImpression → Callback when an ad impression is logged.onAdClosed → Callback when the ad is closed.onAdOpened → Callback when the ad is opened.onAdWillDismissScreen → Callback when the ad is about to dismiss the screen.onPaidEvent → Callback for handling paid events from the ad.✅ Preload early – Call loadNativeAd() on your splash screen or just before the screen where the ad will be shown.
✅ Dispose when unused – Always call disposeNative() when leaving the screen to free memory.
✅ Avoid multiple preload calls – The mixin ensures only one native ad is preloaded at a time.
✅ Handle callbacks – Use onAdClicked, onAdImpression, and onPaidEvent to track engagement and revenue.
✅ Fallback UI – If no ad is preloaded, showNativeAd() automatically shows a loading placeholder.
Admob Easy automatically checks if the device is online before loading ads.
You can check connectivity manually:
AdmobEasy.instance.isConnected.value; // true if connected
Or use a listener:
ValueListenableBuilder(
valueListenable: ConnectivityController.instance.isConnected,
builder: (_, value, child) {
return Text(value ? "Connected" : "No Internet");
},
);
You can also initialize connectivity monitoring:
AdmobEasy.instance.initConnectivity(
onOnline: () => print("Online"),
onOffline: () => print("Offline"),
);
If you find this package useful and want to support its development, you can buy me a coffee:
Thank you for your support!
Feel free to submit bug reports, feature requests, or pull requests on GitHub.