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

PlatformiOS

Production-ready Google AdMob for Flutter. Zero-config widgets for Banner, Native, Interstitial, Rewarded, Rewarded Interstitial, and App Open ads. Built-in iOS ATT and GDPR/UMP consent. Handles all e [...]

flutter_ads_kit #

Production-ready Google AdMob for Flutter. Drop-in widgets and managers for every ad format with built-in iOS ATT, GDPR/UMP consent, preloading, cooldowns, and automatic retry — all behind a clean, minimal API.

Features #

Format Class Notes
Banner BannerAdWidget Adaptive & fixed sizes, orientation reload
Native NativeAdWidget Google Templates + custom factory mode
Interstitial InterstitialAdManager Preload, cooldown, exponential retry
Rewarded RewardedAdManager Preload, exact-once reward callback
Rewarded Interstitial RewardedInterstitialAdManager Same pattern as rewarded
App Open AppOpenAdManager Lifecycle observer, 4 h expiry check
  • iOS App Tracking Transparency (ATT) prompt before the first ad request
  • GDPR / UMP consent form for EEA users with a 10 s safety timeout
  • COPPAtagForChildDirectedTreatment / tagForUnderAgeOfConsent
  • Automatic test ad IDs in kDebugMode — no manual switching
  • Infinite retry with back-off — ads recover automatically after network failures
  • App-resume reload — banner, native, and full-screen ads reload whenever the app comes to the foreground
  • Single import: package:flutter_ads_kit/flutter_ads_kit.dart

Getting started #

1. Add the dependency #

dependencies:
  flutter_ads_kit: ^1.1.0

2. Android setup #

In android/app/src/main/AndroidManifest.xml, inside <application>:

<meta-data
  android:name="com.google.android.gms.ads.APPLICATION_ID"
  android:value="ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX"/>

Minimum SDK: 21. In android/app/build.gradle:

minSdkVersion 21

3. iOS setup #

In ios/Runner/Info.plist:

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX</string>

<!-- Required for ATT prompt -->
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalised ads to you.</string>

Minimum deployment target: 14.0.

4. Provide your ad unit IDs #

Edit lib/src/ad_units.dart (or your own constants file) and replace the test IDs with your real AdMob ad unit IDs for the release flavour.

Usage #

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

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Handles ATT prompt → GDPR consent → AdMob init → preloads all full-screen ads
  await AdsManager.instance.initialize(
    // adsEnabled: false,              // pass false after a "Remove Ads" IAP
    // tagForChildDirectedTreatment: true,  // COPPA
    // testDeviceIds: ['YOUR_DEVICE_HASH'],
  );

  if (AdsManager.instance.isAdsEnabled) {
    AppOpenAdManager.instance.initialize(); // attaches lifecycle observer
  }

  runApp(const MyApp());
}
// Adaptive banner (recommended)
const BannerAdWidget()

// Fixed size
const BannerAdWidget(size: AdSize.mediumRectangle)

Native ad #

// Medium template (no platform setup needed)
const NativeAdWidget()

// Small template
const NativeAdWidget(nativeAdSize: NativeAdSize.small)

For a custom native layout, register a platform factory named 'nativeAdFactory' on each platform (see the example/ directory for the full Android NativeAdFactory.kt and iOS NativeAdFactory.swift) then pass useCustomFactory: true:

NativeAdWidget(useCustomFactory: true)
NativeAdWidget(useCustomFactory: true, customFactoryHeight: 320)

Interstitial #

await InterstitialAdManager.instance.show(
  onAdDismissed: () => goToNextScreen(),
  onNotAvailable: () => showFallback(),
);

Rewarded #

await RewardedAdManager.instance.show(
  onUserEarnedReward: (RewardItem reward) => grantCoins(reward.amount.toInt()),
  onAdDismissed: () { /* optional */ },
);

Rewarded Interstitial #

await RewardedInterstitialAdManager.instance.show(
  onUserEarnedReward: (RewardItem reward) => grantBonus(reward.amount.toInt()),
);

App Open #

// Show manually (e.g. after a splash screen)
AppOpenAdManager.instance.showAdIfAvailable(
  onAdDismissed: () => navigateHome(),
);

// Suppress during a rewarded ad to avoid stacking
AppOpenAdManager.instance.suppress();
AppOpenAdManager.instance.unsuppress();

Disable ads (e.g. after IAP) #

// Pass false during initialisation (before any ad loads):
await AdsManager.instance.initialize(adsEnabled: false);

// Or toggle at runtime after an IAP purchase:
AdsManager.instance.disableAds();   // stops all future ad requests
AdsManager.instance.enableAds();    // re-enables and triggers a fresh preload

Additional information #

Contributions and issues are welcome at the GitHub repository.

0
likes
140
points
29
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Production-ready Google AdMob for Flutter. Zero-config widgets for Banner, Native, Interstitial, Rewarded, Rewarded Interstitial, and App Open ads. Built-in iOS ATT and GDPR/UMP consent. Handles all edge cases automatically.

Repository (GitHub)
View/report issues

Topics

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

License

MIT (license)

Dependencies

app_tracking_transparency, flutter, google_mobile_ads

More

Packages that depend on flutter_ads_kit