The fast_ads
brick will add mobile ads to your Flutter app using the AdMob plugin.
mason make fast_ads
The fast_ads
brick will generate the following files:
+-- lib
+-- features
+-- shared
+-- ui
+-- banner_ad_widget.dart
The banner_ad_widget.dart
file includes code to setup and display a banner ad in your app. The widget loads a banner and displays it in a FutureBuilder
.
The brick will prompt you to enter your AdMob app IDs for Android and iOS
This brick will add the google_mobile_ads package to your pubspec.yaml file.
The following code will be added to the AndroidManifest.xml file:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
The following code will be added to the Info.plist file:
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy</string>
The following line will be added to the main.dart file:
MobileAds.instance.initialize();
To use AdMob, you will need to create an AdMob account and add your app to the AdMob console. You will receive an app ID for Android and iOS. Add these IDs to the brick prompt when asked.
You can also add these app IDs to the assets/config.json
file in the root of your project.