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

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();
  bool apiCallDone = false;

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

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

    try {
      platformVersion = await _akAdsPlugin.getApiResponse(arguments: {"ad_show": true}) ?? 'Unknown platform version';
      apiCallDone = true;
    } 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: apiCallDone
                ? 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,
                      )
                    ],
                  )
                : Container(),
          ),
        ),
        floatingActionButton: FloatingActionButton(onPressed: () {
          scaffoldKey.currentState?.openDrawer();
        }),
      ),
    );
  }
}
3
likes
120
points
24
downloads

Publisher

unverified uploader

Weekly Downloads

Ads plugin for Android only

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on ak_ads_plugin

Packages that implement ak_ads_plugin