monetization_kit 1.0.1 copy "monetization_kit: ^1.0.1" to clipboard
monetization_kit: ^1.0.1 copied to clipboard

A complete Flutter monetization toolkit with AdMob ads, native ads, Firebase Analytics, Crashlytics, Remote Config, force updates, and utilities for production apps.

example/lib/main.dart

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

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

  await MonetizationKit.initialize(
    config: const MonetizationConfig(
      iosStoreId: 'YOUR_IOS_APP_STORE_ID',
      adUnitIds: AdUnitIds(
        androidBanner: 'YOUR_ANDROID_BANNER_ID',
        iosBanner: 'YOUR_IOS_BANNER_ID',

        androidInterstitial: 'YOUR_ANDROID_INTERSTITIAL_ID',
        iosInterstitial: 'YOUR_IOS_INTERSTITIAL_ID',

        androidRewarded: 'YOUR_ANDROID_REWARDED_ID',
        iosRewarded: 'YOUR_IOS_REWARDED_ID',

        androidAppOpen: 'YOUR_ANDROID_APP_OPEN_ID',
        iosAppOpen: 'YOUR_IOS_APP_OPEN_ID',

        androidNativeSmall: 'YOUR_ANDROID_NATIVE_ID',
        iosNativeSmall: 'YOUR_IOS_NATIVE_ID',

        androidNativeMedium: 'YOUR_ANDROID_NATIVE_ID',
        iosNativeMedium: 'YOUR_IOS_NATIVE_ID',

        androidNativeFull: 'YOUR_ANDROID_NATIVE_ID',
        iosNativeFull: 'YOUR_IOS_NATIVE_ID',
      ),
    ),
  );

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorObservers: [AnalyticsService.observer],
      home: const HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  Future<void> _showInterstitial(BuildContext context) async {
    await InterstitialAdService.show(context: context);
  }

  Future<void> _showRewarded() async {
    await RewardedAdService.show(
      onRewardEarned: (reward) {
        debugPrint('Reward earned: ${reward.amount} ${reward.type}');
      },
    );
  }

  Future<void> _showNativePopup(BuildContext context) async {
    await NativePopupAd.show(context, type: NativeAdType.full);
  }

  Future<void> _tapAd(BuildContext context) async {
    final shouldShow = AdFrequencyManager.shouldShow(
      placement: 'home_button',
      showEvery: RemoteConfigService.interstitialClickCount,
      cooldown: const Duration(seconds: 30),
    );

    if (shouldShow) {
      await InterstitialAdService.show(context: context);

      AdFrequencyManager.markShown(placement: 'home_button');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: const BannerAdWidget(collapsible: false),
      appBar: AppBar(title: const Text('Monetization Kit Example')),
      body: ListView(
        padding: const EdgeInsets.all(16),
        children: [
          ElevatedButton(
            onPressed: () => _showInterstitial(context),
            child: const Text('Show Interstitial'),
          ),
          ElevatedButton(
            onPressed: _showRewarded,
            child: const Text('Show Rewarded'),
          ),
          ElevatedButton(
            onPressed: () => _showNativePopup(context),
            child: const Text('Show Native Popup'),
          ),
          ElevatedButton(
            onPressed: () => _tapAd(context),
            child: const Text('Tap Counter Ad'),
          ),
          ElevatedButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (_) => const FeedbackScreen(
                    webhookUrl: 'YOUR_DISCORD_WEBHOOK_URL',
                  ),
                ),
              );
            },
            child: const Text('Feedback Screen'),
          ),
          ElevatedButton(
            onPressed: () async {
              await FullscreenNativeTimerAd.show(
                context,
                duration: const Duration(seconds: 10),
              );
            },
            child: const Text('Fullscreen Timer Ad'),
          ),
          const SizedBox(height: 20),
          const NativeAdWidget(type: NativeAdType.small, useCache: true),
          const SizedBox(height: 20),
          const NativeAdWidget(type: NativeAdType.medium, useCache: true),
          const SizedBox(height: 20),
          const NativeAdWidget(type: NativeAdType.full, useCache: true),
        ],
      ),
    );
  }
}
2
likes
130
points
361
downloads
screenshot

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A complete Flutter monetization toolkit with AdMob ads, native ads, Firebase Analytics, Crashlytics, Remote Config, force updates, and utilities for production apps.

Homepage
Repository

License

unknown (license)

Dependencies

device_info_plus, dio, firebase_analytics, firebase_core, firebase_crashlytics, firebase_remote_config, flutter, google_mobile_ads, image_picker, in_app_update_flutter, package_info_plus, permission_handler, shared_preferences, shimmer_animation

More

Packages that depend on monetization_kit

Packages that implement monetization_kit