Table of Contents
š¢ This package has been discontinued in April 2021 in favor of Google Mobile Ads SDK for Flutter. Please refer our new guide for Google Mobile Ads SDK for Flutter
Our New Guide :Ā Monetizing Flutter Apps š”
Flutter Package :Ā Google Mobile Ads SDK for Flutter ā
āFlutter Package : firebase_admob
It is a plugin for flutter that supports loading and displaying banner, interstitial(full-screen), and rewarded video ads using Firebase AdMob API.ā
Learn More :Ā firebase_admob
Firebase AdMob Package |
firebase_admob: ^0.9.0+9
To learn how to use packages in flutter refer our Using Flutter Packages Guide
Adding Flutter Package |
<manifest>
<application>
<!-- TODO: Replace with your real AdMob app ID -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-################~##########"/>
</application>
</manifest>
Adding meta-data to AndroidManifest.xml |
Note : Use Stateful Widgets
This is a simple app demo to learn how to integrate admob ads in your flutter app.
Define Banner Ad Property |
load banner ad |
Select BannerAd button to open a BannerAd Page
Demo App HomeScreen - BannerAd |
Banner Ad Demo Ad 1 - buildBannerAd()
Banner Ad Demo 1 |
Banner Ad Demo Ad 2 - buildLargeBannerAd()
Banner Ad Demo 2 |
MobileAdEvent.closed - user closes a ad
this load() method keeps another ad ready to be displayed when the right time comes ie. show() method is invoked
Define Interstitial Ad Property |
load interstitial ad |
show interstitial ad |
Note:Ā Enable WiFi or mobile network on your test device or emulator to see test ads.
Select InterstitialAd button to open Interstitial Ad Page
Demo App HomeScreen - Interstitial Ad |
Flutter Interstitial Ad Demo |
This guide explains how to enable test ads in your app. These ad units are not associated with your AdMob account and are sample ad units that are used for building and testing your apps.
Note : If you want to publish your app to Play Store or App Store then you will have to add your AdMob app ID in your AndroidManifest.xml file. Once you find your AdMob app ID in the AdMob UI add it to your AndroidManifest.xml file as explained in step 2.
<manifest>
<application>
<!-- TODO: Replace with your real AdMob app ID -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-################~##########"/>
</application>
</manifest>
Also replace testAdUnitId with an ad unit ids from AdMob to display real ads to your app users.
BannerAd buildBannerAd() {
return BannerAd(
// Replace the testAdUnitId with an ad unit id from the AdMob dash.
adUnitId: BannerAd.testAdUnitId,
size: AdSize.banner,
...
}