Simple ads manager package for personal use. Not for public but if you want to use, you can use it. However, I am not guarantee to up-to-date.

Features

Currently, only google_mobile_ads has been added. You can add other ads services as you want.

  • Banner Ad with simple BannerAdView widget
  • Native Ad with default NativeTemplateStyle and NativeAdView widget
  • Interstitial Ad
  • Rewarded Ad
  • AppOpen Ad with LifecycleInteractor and AppOpenAdWidget.

Getting started

Before you use this package, you must do native and other configurations according to the documentation of ads service provider. For google AdMod - https://developers.google.com/admob/flutter/quick-start

Usage

Create Adapter and Repository.

final config = AdsConfig(enabled: true);

// We use `google` adapter here.
final adapter = GoogleAdsAdapter();
final repo = AdsRepository(adapter, config);
final bannerAd = await repo.loadBanner("adUnitId", width: 280, height: 70);
final bannerAdWidget = bannerAd.widget;

final nativeAd = await repo.loadNative("adUnitId");
final nativeAdWidget = nativeAd.widget;

or

FutureBuilder<BannerAdController>(
    // You can change loadNative() here
    future: repo.loadBanner("YOUR_AD_UNIT_ID", width: 280, height: 20),
    builder: (context, snapshot) {
        if (snapshot.connectionState == ConnectionState.waiting) {
            return const SizedBox.shrink();
        }
        if (snapshot.hasError || !snapshot.hasData) {
            return const SizedBox.shrink();
        }
        final controller = snapshot.data!;
        return SizedBox(height: height, child: controller.widget);
    },
)

Interstitial

final inter = await repo.loadInterstitial("adUnitId");
await inter.show();

Rewarded

final rewarded = await repo.loadRewarded("adUnitId");
await rewarded.showRewarded((amount, type) {});

AppOpen

final appOpenAd = await repo.loadAppOpen("adUnitId");
await appOpenAd.show();

Libraries

my_ads_manager
Simple Ads Manager package