flutter_ads_plugin 0.0.9 copy "flutter_ads_plugin: ^0.0.9" to clipboard
flutter_ads_plugin: ^0.0.9 copied to clipboard

Effortlessly integrate and manage Google Ads in your Flutter app with minimal code. Simplifies ad creation and boosts monetization potential.

example/lib/main.dart

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

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  MobileAds.instance.initialize();
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  showRewardedAd() {
    FlutterAdsRewarded.show(
        androidId: '',
        iosId: '',
        onUserEarnedReward: (view, item) {
          //TODO
        },
        onError: (e) {
          //TODO
        },
        onClose: () {
          //TODO
        });
  }

  showInterstitialAd() {
    FlutterAdsInterstitial.show(
        androidId: '',
        iosId: '',
        onError: (e) {
          //TODO
        },
        onClose: () {
          //TODO
        });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
          ),
          body: Column(
            mainAxisSize: MainAxisSize.max,
            children: [
              const SizedBox(height: 24),
              const FlutterAdsBanner(
                iosId: '',
                androidId: '',
              ),
              const SizedBox(height: 24),
              const FlutterAdsNative(
                androidId: '',
                iosId: '',
                templateStyle: null,
                factoryId: null,
                constraints: null,
              ),
              ElevatedButton(
                  onPressed: showRewardedAd,
                  child: const Text('Show Rewarded Ad')),
              const SizedBox(height: 24),
              ElevatedButton(
                  onPressed: showInterstitialAd,
                  child: const Text('Show Interstitial Ad')),
            ],
          )),
    );
  }
}
copied to clipboard
5
likes
0
points
122
downloads

Publisher

unverified uploader

Weekly Downloads

2024.06.01 - 2025.04.26

Effortlessly integrate and manage Google Ads in your Flutter app with minimal code. Simplifies ad creation and boosts monetization potential.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

equatable, flutter, flutter_bloc, google_mobile_ads

More

Packages that depend on flutter_ads_plugin