my_ads_plugin 1.0.0 copy "my_ads_plugin: ^1.0.0" to clipboard
my_ads_plugin: ^1.0.0 copied to clipboard

PlatformAndroid

A Flutter plugin for displaying image, video, and HTML ads easily.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:my_ads_plugin/ad_controllers/image_ad_controller.dart';
import 'package:my_ads_plugin/ad_controllers/html_ad_controller.dart';
import 'package:my_ads_plugin/ad_controllers/video_ad_controller.dart'; // import VideoAdController

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Ad Plugin Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomeScreen(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Ad Plugin Demo"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                // Navigate to Banner Ad
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (_) =>
                        ImageAdController(adUnitId: "test_image_ad"),
                  ),
                );
              },
              child: const Text("Show Banner Ad"),
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (_) => HtmlAdController(adUnitId: "test_html_ad"),
                  ),
                );
              },
              child: const Text("Show Playable Ad"),
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                // Navigate to Video Ad
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (_) =>
                        const VideoAdController(adUnitId: "test_video_ad"),
                  ),
                );
              },
              child: const Text("Show Video Ad"),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
160
points
3
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for displaying image, video, and HTML ads easily.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface, url_launcher, video_player, webview_flutter

More

Packages that depend on my_ads_plugin

Packages that implement my_ads_plugin