An easy way to add all google ads to your flutter app
Google Ads
An easy way to add all google ads to your flutter app.
How to use it
-
Add the google_mobile_ads package using
flutter pub add google_mobile_ads
. -
Update your Info.plist as follows:
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>cstr6suwn9.skadnetwork</string>
</dict>
</array>
- Add the AdMob App ID (identified in the AdMob UI) to the app’s
android/app/src/main/AndroidManifest.xml
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
-
Add id’s of
(rewardedID &&interstitialID && bannerID)
in ads.dart insideif(kReleaseMode)
. -
To use banner just write
AdBanner()
inside any widget. -
To use rewarded just write
AdReWarded.instance.createRewardedAd()
insideinitState()
method and writeAdReWarded.instance.dispose
insidedispose()
method. -
To use interstitial just write
AdInterstitial.instance.createInterstitialAd()
insideinitState()
method and writeAdInterstitial.instance.dispose
insidedispose()
method.