admob_widgets 1.2.0 copy "admob_widgets: ^1.2.0" to clipboard
admob_widgets: ^1.2.0 copied to clipboard

A flutter package that provide widgets to apply easily admob unities.

Admob Widgets #

A variety of widgets to use easily ad units of AdMob

Getting started #

Android #

Modify the AndroidManifest.xml adding the next

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

In application tag, add the next

<meta-data
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="ca-app-pub-{your application ID}"/>

Finally in the main add the next code

void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  AdMobWidgets.instance(
    androidBannerAdUnitId: "{Your banner ad unit Id}", 
    androidInterstitialAdUnitId: "Your intertitial ad unit Id"
    );
  await MobileAds.instance.initialize();
  runApp(const MainApp());
}

Usage #

// Only call the widget
const BannerWidget();

Instertitial #

// Initialize the the class InterstitialUnit
final interstitialUnit = InterstitialUnit();
// Initialize InterstitialAd
InterstitialAd? _interstitialAd;

@override
  void initState() {
    super.initState();
    // Load the ad
    interstitialUnit.loadAd();
  }

setState(() {
    //Asign the class's intertitial to local interstitial
      _interstitialAd = interstitialUnit.interstitialAd;
      // check interstital is not null
        if(_interstitialAd != null){
            // show the interstitial
          _interstitialAd!.show();
          // reload the interstitial
          interstitialUnit.loadAd();
        }
    });
3
likes
160
points
38
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter package that provide widgets to apply easily admob unities.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, google_mobile_ads

More

Packages that depend on admob_widgets