flutter_admobs_handler 1.1.6 copy "flutter_admobs_handler: ^1.1.6" to clipboard
flutter_admobs_handler: ^1.1.6 copied to clipboard

Reusable AdMob utilities for Flutter with banner, native advanced, app open, interstitial, rewarded, and rewarded interstitial ads, test/production switching, and a central AppAdsUtil configuration API.

[Flag of Pakistan]

Made in Pakistan with Love ❤️


flutter_admobs_handler

pub version MIT License Flutter AdMob Author Made in Pakistan

Six ad formats · One config API · Production-ready from day one
Reusable AdMob utilities for Flutter — banner, native, app open, interstitial,
rewarded & rewarded interstitial — with safe test/production switching.

Features · Install · Quick Start · Usage · Example · Author


Made in Pakistan with Love ❤️ #

[Flag of Pakistan]

flutter_admobs_handler is crafted in Pakistan for Flutter developers worldwide — clean monetization without the boilerplate, the guesswork, or the late-night AdMob debugging sessions.

Built on google_mobile_ads ^9.1.0 (Dart 3.10+ · Flutter 3.38+ · Gradle 9 ready).

👤 About the author #

[Flag of Pakistan]

Love

Junaid Hassan · juni12891226 #

Role Senior Mobile Application Developer · Solution Architect
Location Pakistan
GitHub @juni12891226
Phone +92-321-8510164

✨ Features #

📺 Ad formats — every major Google placement #

Format Utility Widget Highlights
🟦 Banner BannerAdUtil AdMobBannerWidget Adaptive width · NO_FILL fallback
🟩 Native Advanced NativeAdUtil AdMobNativeWidget Templates · custom factoryId
🟪 App Open AppOpenAdUtil 4h cache · showIfAvailable()
🟧 Interstitial InterstitialAdUtil Preload · natural breakpoints
🟨 Rewarded RewardedAdUtil RewardedAdShowResult
🟥 Rewarded Interstitial RewardedInterstitialAdUtil Full-screen · SSV support
🧩 Drop-in widgets · ⚙️ Configuration · 🛡️ Safeguards · 🚀 DX — click to expand

🧩 Drop-in widgets

Widget What it does
AdMobBannerWidget Self-loading adaptive/fixed banner with lifecycle handling
AdMobNativeWidget Inline native advanced with template styling & height control

⚙️ Central configuration — AppAdsUtil

  • One singleton for all ad unit IDs (Android + iOS per format)
  • configure() — set everything in one call before SDK init
  • useTestAds — global test/production switch (safe defaults)
  • testDeviceIds — register devices for safe production-unit testing
  • Publisher mismatch logging at startup

🛡️ Production-ready safeguards

  • Fallback to Google official test ad units when IDs are missing
  • Bounded exponential backoff for transient NO_FILL responses
  • RewardedAdShowResult — reliable reward tracking
  • AdMobAdState lifecycle on every util
  • Graceful no-op on web/desktop
  • Optional structured logging via onLog

🚀 Developer experience

  • Fully documented public API (dartdoc on every export)
  • Runnable Android + iOS example with Google test inventory
  • Strict analysis & CI-friendly tests
  • MIT licensed — personal & commercial use

📱 Platform support #

Platform Status
🤖 Android Supported
🍎 iOS Supported
🌐 Web Not supported
🖥️ Desktop Not supported

📦 Installation #

Add to pubspec.yaml:

dependencies:
  flutter_admobs_handler: ^1.1.6

Then run:

flutter pub get

Native setup #

Declare your AdMob application ID in the platform manifests (separate from ad unit IDs — must belong to the same AdMob account).

🤖 Android
android/app/src/main/AndroidManifest.xml
<meta-data
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY" />
🍎 iOS
ios/Runner/Info.plist
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY</string>

While testing, use Google's sample application IDs from AdMobAdsConstants.androidTestApplicationId and AdMobAdsConstants.iosTestApplicationId.


🚀 Quick start #

import 'package:flutter/material.dart';
import 'package:flutter_admobs_handler/flutter_admobs_handler.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  AppAdsUtil.instance
    ..publisherId = '7730187684799569'
    ..bannerAndroidAdUnitId = 'ca-app-pub-7730187684799569/3242657265'
    ..interstitialAndroidAdUnitId = 'ca-app-pub-7730187684799569/1683635764'
    ..rewardedAndroidAdUnitId = 'ca-app-pub-7730187684799569/4364167242'
    ..rewardedInterstitialAndroidAdUnitId =
        'ca-app-pub-7730187684799569/REWARDED_INTERSTITIAL_ANDROID'
    ..nativeAndroidAdUnitId = 'ca-app-pub-7730187684799569/NATIVE_ANDROID'
    ..appOpenAndroidAdUnitId = 'ca-app-pub-7730187684799569/APP_OPEN_ANDROID'
    ..useTestAds = false
    ..testDeviceIds = ['YOUR_TEST_DEVICE_HASH']
    ..onLog = debugPrint;

  await AppAdsUtil.instance.initializeAdsSdk();
  runApp(const MyApp());
}

Or configure in one call via AppAdsUtil.configure.


📖 Usage #

🟦 Banner
const AdMobBannerWidget(useAdaptiveWidth: true)

Omit adUnitIds to use AppAdsUtil.bannerAdUnitIds.

🟩 Native advanced
const AdMobNativeWidget(templateType: TemplateType.medium)

Or load manually:

final native = NativeAdUtil(
  adUnitIds: AppAdsUtil.instance.nativeAdUnitIds,
  nativeTemplateStyle: NativeTemplateStyle(templateType: TemplateType.medium),
);

await native.load();
final widget = native.buildWidget();
native.dispose();

Omit adUnitIds to use AppAdsUtil.nativeAdUnitIds. For custom platform layouts, pass factoryId instead of nativeTemplateStyle.

🟪 App open

Preload on startup; show when the app returns to the foreground:

final appOpen = AppOpenAdUtil(
  adUnitIds: AppAdsUtil.instance.appOpenAdUnitIds,
);

await appOpen.load();

// On resume (WidgetsBindingObserver.didChangeAppLifecycleState):
await appOpen.showIfAvailable();

await appOpen.show(); // or show immediately when ready
appOpen.dispose();

Loaded ads expire after four hours by default (AdMobAdsConstants.defaultAppOpenCacheDuration); expired inventory is discarded and reloaded automatically.

🟧 Interstitial
final interstitial = InterstitialAdUtil(
  adUnitIds: AppAdsUtil.instance.interstitialAdUnitIds,
);

await interstitial.load();
await interstitial.show();
interstitial.dispose();
🟨 Rewarded
final rewarded = RewardedAdUtil(
  adUnitIds: AppAdsUtil.instance.rewardedAdUnitIds,
);

await rewarded.load();
final result = await rewarded.show(onUserEarnedReward: (reward) {
  // grant the reward
});
if (result.shown && result.rewardEarned) {
  // user completed the ad
}
rewarded.dispose();
🟥 Rewarded interstitial
final rewardedInterstitial = RewardedInterstitialAdUtil(
  adUnitIds: AppAdsUtil.instance.rewardedInterstitialAdUnitIds,
);

await rewardedInterstitial.load();
final result = await rewardedInterstitial.show(onUserEarnedReward: (reward) {
  // grant the reward
});
if (result.shown && result.rewardEarned) {
  // user completed the ad
}
rewardedInterstitial.dispose();
🧪 Test ads

AppAdsUtil.useTestAds defaults to true, serving Google's official test inventory on every placement.

Register test devices via AppAdsUtil.testDeviceIds to request production unit IDs while still receiving test creatives during development. Each device prints its hash in logcat as Use RequestConfiguration.Builder().setTestDeviceIds(...).


🎮 Example #

See the example/ directory for a runnable Android/iOS sample covering all six ad formats.

cd example
flutter pub get
flutter run

🤝 Contributing #

Issues and pull requests are welcome on GitHub.


[Flag of Pakistan — Made with Love]

Made in Pakistan with Love ❤️

Junaid Hassan · @juni12891226
Senior Mobile Application Developer · Solution Architect · Pakistan
📞 +92-321-8510164

MIT License · Built for Flutter developers worldwide 🌍

License #

MIT — see LICENSE.

2
likes
0
points
252
downloads

Publisher

unverified uploader

Weekly Downloads

Reusable AdMob utilities for Flutter with banner, native advanced, app open, interstitial, rewarded, and rewarded interstitial ads, test/production switching, and a central AppAdsUtil configuration API.

Repository (GitHub)
View/report issues

Topics

#admob #ads #advertising #google-mobile-ads #monetization

License

unknown (license)

Dependencies

flutter, google_mobile_ads

More

Packages that depend on flutter_admobs_handler