ad_flow 1.3.1 copy "ad_flow: ^1.3.1" to clipboard
ad_flow: ^1.3.1 copied to clipboard

Easy AdMob integration for Flutter with banner, interstitial, rewarded, native & app open ads, plus built-in GDPR/ATT consent management.

example/lib/main.dart

// Copyright 2024 - AdMob Integration Demo
// Production-ready example demonstrating all ad features

import 'package:flutter/material.dart';
import 'package:ad_flow/ad_flow.dart';
import 'pages/demo_home_page.dart';

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

  // Initialize the ad service with test mode configuration
  // For production, use AdFlowConfig() with your real ad unit IDs:
  //
  // config: AdFlowConfig(
  //   androidBannerAdUnitId: 'ca-app-pub-YOUR_ID/BANNER_ID',
  //   iosBannerAdUnitId: 'ca-app-pub-YOUR_ID/BANNER_ID',
  //   androidInterstitialAdUnitId: 'ca-app-pub-YOUR_ID/INTERSTITIAL_ID',
  //   iosInterstitialAdUnitId: 'ca-app-pub-YOUR_ID/INTERSTITIAL_ID',
  //   // ... other ad unit IDs
  // ),
  await AdFlow.instance.initialize(
    config: AdFlowConfig.testMode(), // Use Google's test ad IDs
    onComplete: (canRequestAds) {
      debugPrint('═══════════════════════════════════════════');
      debugPrint('AdFlow initialized!');
      debugPrint('Can request ads: $canRequestAds');
      debugPrint('Ads enabled: ${AdFlow.instance.isAdsEnabled}');
      debugPrint('═══════════════════════════════════════════');
    },
    preloadInterstitial: true,
    preloadAppOpen: true,
    showAppOpenOnColdStart: true,
    enableAppOpenOnForeground: false,
    maxForegroundAdsPerSession: 1,
  );

  runApp(const AdDemoApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'AdMob Integration Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.indigo,
          brightness: Brightness.light,
        ),
        useMaterial3: true,
        cardTheme: const CardThemeData(
          elevation: 2,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(16)),
          ),
        ),
        filledButtonTheme: FilledButtonThemeData(
          style: FilledButton.styleFrom(
            padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 14),
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(12),
            ),
          ),
        ),
      ),
      darkTheme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.indigo,
          brightness: Brightness.dark,
        ),
        useMaterial3: true,
      ),
      home: const DemoHomePage(),
    );
  }
}
2
likes
0
points
726
downloads

Publisher

verified publisherfaizahmaddae.com

Weekly Downloads

Easy AdMob integration for Flutter with banner, interstitial, rewarded, native & app open ads, plus built-in GDPR/ATT consent management.

Repository (GitHub)
View/report issues

Topics

#admob #ads #monetization #gdpr

License

unknown (license)

Dependencies

app_tracking_transparency, flutter, google_mobile_ads, shared_preferences

More

Packages that depend on ad_flow