ak_ads_plugin 0.0.6 copy "ak_ads_plugin: ^0.0.6" to clipboard
ak_ads_plugin: ^0.0.6 copied to clipboard

outdated

Ads plugin for Android only

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:ak_ads_plugin/ak_ads_plugin.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  final _akAdsPlugin = AkAdsPlugin();

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    String platformVersion;

    try {
      platformVersion = await _akAdsPlugin.getApiResponse() ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }
  var scaffoldKey = GlobalKey<ScaffoldState>();


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        key: scaffoldKey,

        drawer: Drawer(),
        drawerEnableOpenDragGesture: false,
        appBar: AppBar(
          title: const Text('Plugin example app'),
          leading: Builder(
            builder: (context) => // Ensure Scaffold is in context
                IconButton(icon: Icon(Icons.menu), onPressed: () => Scaffold.of(context).openDrawer()),
          ),
        ),
        backgroundColor: Colors.red,
        body: SizedBox(
          height: MediaQuery.of(context).size.height,
          child: SingleChildScrollView(
            child: Column(
              children: [
                BannerAdView(),
                NativeAdView(
                  adSize: "small",
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 8.0),
                  child: NativeAdView(
                    adSize: "medium",
                  ),
                ),
                NativeAdView(
                  adSize: "big",
                ),
                QuizAdView(),
                MaterialButton(
                  onPressed: () {
                    _akAdsPlugin.callInterstitialAds();
                  },
                  child: Text("Inter Click"),
                  color: Colors.blueGrey,
                )
              ],
            ),
          ),
        ),
        floatingActionButton: FloatingActionButton(onPressed: () {
          scaffoldKey.currentState?.openDrawer();
        }),
      ),
    );
  }
}