Easy AdMob Integration for Flutter
A simple, configurable Flutter wrapper for Google AdMob. One EasyAdMobAds.instance sets up the SDK, GDPR/UMP consent, and a global on/off switch for ads. All six ad formats are supported with their own controller or widget.
Show some ❤️ by giving the repo a ⭐ and liking 👍 the package on pub.flutter-io.cn!
Screenshots
Features
- Banner (adaptive, optionally collapsible)
- Interstitial
- Rewarded
- Rewarded Interstitial
- App Open (auto-preloaded and shown on app resume)
- Native (small/medium templates)
- GDPR/UMP consent flow, including the "privacy options" re-consent form
- App Tracking Transparency (ATT) consent on iOS 14.5+, requested automatically during
initialize() - Network connectivity awareness — ad requests pause while offline and resume as soon as connectivity returns
AdMob Mediation
This package supports Meta Audience Network through AdMob Mediation. Configure Meta or other ad networks in your AdMob dashboard while using the same ad widgets and controllers. Each additional network also needs its mediation adapter integrated into your Flutter app.
See Google's AdMob Mediation setup guide and Meta Audience Network integration guide.
Getting started
1. Install
dependencies:
easy_admob_ads_flutter: ^<latest_version>
2. Platform setup
Add your AdMob App ID:
Android — android/app/src/main/AndroidManifest.xml:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
iOS — ios/Runner/Info.plist:
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy</string>
Meta mediation with SwiftPM (iOS)
If AdMob reports “No such adapter in the application” for Meta Audience Network, add a direct reference to the adapter in ios/Runner/AppDelegate.swift. SwiftPM may embed MetaAdapter.framework without retaining its class for AdMob's runtime lookup.
import Flutter
import MetaAdapter
import UIKit
@main
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
_ = GADMediationAdapterFacebook.adapterVersion()
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
}
}
The adapterVersion() call keeps the Meta adapter linked so AdMob can discover it.
3. Initialize
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await EasyAdMobAds.instance.initialize(
config: const EasyAdsConfig(
androidAdUnitIds: {
AdType.banner: 'ca-app-pub-.../...',
AdType.interstitial: 'ca-app-pub-.../...',
},
iosAdUnitIds: {
AdType.banner: 'ca-app-pub-.../...',
AdType.interstitial: 'ca-app-pub-.../...',
},
testDeviceIds: ['YOUR_TEST_DEVICE_ID'],
),
);
runApp(const MyApp());
}
Any AdType you don't configure automatically falls back to a Google test ad unit ID
(with a warning logged), so the package works out of the box during development.
Usage
// Banner
const EasyBannerAd(collapsible: true, height: 100)
// Native
EasyNativeAd.medium()
// Interstitial
final interstitialAd = EasyInterstitialAd()..loadAd();
await interstitialAd.showAd();
// Rewarded
final rewardedAd = EasyRewardedAd(onRewardEarned: (reward) {
// grant the reward
})..loadAd();
await rewardedAd.showAd();
// Rewarded Interstitial
final rewardedInterstitialAd = EasyRewardedInterstitialAd(onRewardEarned: (reward) {
// grant the reward
})..loadAd();
await rewardedInterstitialAd.showAd();
// App Open — preloaded automatically; show it manually if you want:
await EasyAdMobAds.instance.appOpenAd?.showAdIfAvailable();
// Turn all ads on/off (e.g. after a "remove ads" purchase)
EasyAdMobAds.instance.adsEnabled = false;
// GDPR privacy options
if (EasyAdMobAds.instance.isPrivacyOptionsRequired) {
EasyAdMobAds.instance.showPrivacyOptionsForm();
}
See the example/ app for a full demo screen with all ad types,
the on/off switch, and the consent button wired up.