Drop-in AdMob monetization kit for Flutter built for indie Play Store apps:
- Zero accidental live ad clicks in debug/profile builds — automatically swaps in official Google test unit IDs unless running a release build (protects your AdMob account).
- Anti-spam interstitial protection — new-user grace period (default 10 min), action counter (default every 3rd action), cooldown timer (default 90s), and per-session cap (default 6).
- 1-line remote kill-switch for
app_pulse_kit— turn ads OFF globally across all users anytime without an app update (controller.syncWithRemoteFlag(...)), plus persistent Pro / VIPsetAdFree(true). - Drop-in
SmartBannerAd— anchored adaptive banner that smoothly collapses and disposes itself when ads are disabled, ad-free, or fail to load. - Friendly EN / বাংলা Rewarded Unlock Dialog —
showRewardedWithPrompt(...)with automatic instant grant for VIP / kill-switched users so features never break. - Non-blocking UMP GDPR consent + safe desktop/web/test platform guards +
FakeAdBackendfor deterministic tests.
dependencies:
smart_ad_kit:
git:
url: https://github.com/Keshab1997/smart_ad_kit.git
ref: mainAdd your AdMob App ID inside <application> in android/app/src/main/AndroidManifest.xml:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713" />(Replace the sample App ID above with your real AdMob App ID before Play Store release, and make sure your developer website hosts app-ads.txt.)
import 'package:smart_ad_kit/smart_ad_kit.dart';
final adController = SmartAdController(
config: const SmartAdConfig(
unitIds: AdUnitIds(
androidBanner: 'ca-app-pub-XXXX/banner',
androidInterstitial: 'ca-app-pub-XXXX/interstitial',
androidRewarded: 'ca-app-pub-XXXX/rewarded',
),
newUserGracePeriod: Duration(minutes: 10),
actionsBetweenInterstitials: 3,
minInterstitialInterval: Duration(seconds: 90),
maxInterstitialsPerSession: 6,
),
);
await adController.init();
// Optional: 1-line remote kill-switch from app_pulse_kit!
// adController.syncWithRemoteFlag(
// pulse.flags.isEnabled('ads_enabled', defaultValue: true),
// );Scaffold(
body: MyScreenBody(),
bottomNavigationBar: SmartBannerAd(controller: adController),
)await adController.recordActionAndMaybeShowInterstitial();final result = await adController.showRewardedWithPrompt(
context,
strings: isBangla ? const AdStrings.bn() : const AdStrings.en(),
);
if (result.granted) {
unlockFeature();
}6. Inspect live state in your hidden Debug Sheet
AdDiagnosticsSheet.show(
context,
controller: adController,
strings: isBangla ? const AdStrings.bn() : const AdStrings.en(),
);Use FakeAdBackend in your app's widget tests so tests stay 100% deterministic with zero native platform channel crashes:
final adController = SmartAdController(backend: FakeAdBackend());
await adController.init();Run checks locally:
python3 tool/preflight.py
flutter analyze --fatal-infos
flutter test