simple_admob_native_ad 1.2.1 copy "simple_admob_native_ad: ^1.2.1" to clipboard
simple_admob_native_ad: ^1.2.1 copied to clipboard

A simple, compact Flutter plugin for displaying Google AdMob native ads as banners with auto-refresh and lifecycle management.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:simple_admob_native_ad/simple_admob_native_ad.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'SimpleAdmobNativeAd Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.blue,
          brightness: Brightness.light,
        ),
        useMaterial3: true,
      ),
      darkTheme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.blue,
          brightness: Brightness.dark,
        ),
        useMaterial3: true,
      ),
      themeMode: ThemeMode.system,
      home: const MyHomePage(),
    );
  }
}

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

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final _timerController = SimpleNativeAdTimerController();

  @override
  void dispose() {
    _timerController.stopTimer?.call();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('SimpleAdmobNativeAd Example'),
      ),
      body: Column(
        children: [
          Expanded(
            child: ListView.builder(
              itemCount: 20,
              itemBuilder: (context, index) {
                return ListTile(
                  title: Text('Item $index'),
                  subtitle: Text('This is item number $index'),
                );
              },
            ),
          ),
          // Native Ad Banner
          SafeArea(
            child: SimpleNativeAd(
              // Use test ad unit IDs from ad_util.dart
              iosAdUnitId: testNativeAdUnitIdIOS,
              androidAdUnitId: testNativeAdUnitIdAndroid,
              timerController: _timerController,
              showBorderTop: true,
            ),
          ),
        ],
      ),
    );
  }
}
1
likes
140
points
32
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

A simple, compact Flutter plugin for displaying Google AdMob native ads as banners with auto-refresh and lifecycle management.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, google_mobile_ads, plugin_platform_interface

More

Packages that depend on simple_admob_native_ad

Packages that implement simple_admob_native_ad