admost_flutter_plugin

A new Flutter plugin that uses native platform views to show AdMost mediation platform banner ads!

This plugin also has support for Interstitial and Reward ads.

Installation

Add this to your pubspec.yml dependencies:

admost_flutter_plugin: "^0.0.3"

Add the related dependencies into android/app/build.graddle. Dependencies changes according to your ad network choices. The items shown below represents Facebook audience network dependencies chosen as sample. Refer to the admost android documentation for necessary dependencies for selected ad networks for an application.

    dependencies {
     implementation 'com.admost.sdk:facebook:5.4.0.a10'  
     implementation 'com.android.support:recyclerview-v7:27.1.1' 
    }

It may be needed to add extra repository based on ad network selection. This configuration can be found in the admost android documentation as well.

Simple Example

import 'package:flutter/material.dart';  
import 'package:admost_flutter_plugin/admost.dart';  
import 'package:admost_flutter_plugin/admost_interstitial.dart';  
import 'package:admost_flutter_plugin/admost_rewarded.dart';  
import 'package:admost_flutter_plugin/admost_ad_events.dart';  
import 'package:admost_flutter_plugin/admost_banner.dart';  
import 'package:admost_flutter_plugin/admost_banner_size.dart';  
  
void main() {  
  Admost.initialize('6cc8e89a-b52a-4e9a-bb8c-579f7ec538fe');  
  runApp(MyApp());  
}  
/// This Widget is the main application widget.  
class MyApp extends StatelessWidget {  
  static const String _title = 'Flutter Code Sample';  
  
  @override  
  Widget build(BuildContext context) {  
    return MaterialApp(  
      title: _title,  
  home: Scaffold(  
        appBar: AppBar(title: const Text(_title)),  
  body: MyHomePage(),  
  ),  
  );  
  }  
}  
  
/// This is the stateless widget that the main application instantiates.  
class MyHomePage extends StatefulWidget  
{  
  MyHomePage({Key key}) : super(key: key);  
  
  @override  
  _MyHomePageState createState() => _MyHomePageState();  
  
}  
  
class _MyHomePageState extends State<MyHomePage> {  
  String interstitialText = 'Load Interstitial';  
  String rewardedText = 'Load Rewarded';  
  
  AdmostInterstitial interstitialAd;  
  AdmostRewarded rewardAd;  
  
  @override  
  Widget build(BuildContext context) {  
    return  
  Padding(  
        padding: EdgeInsets.all(10),  
  child: Center(  
          widthFactor: 2,  
  heightFactor: 2,  
  child: Column(  
              children: <Widget>[  
                Card(  
                  child: InkWell(  
                    splashColor: Colors.blue.withAlpha(30),  
  onTap: () async {  
                      if (interstitialAd == null) {  
                        interstitialAd = AdmostInterstitial(  
                          zoneId: 'f99e409b-f9ab-4a2e-aa9a-4d143e6809ae',  
  listener: (AdmostAdEvent event,  
  Map<String, dynamic> args) {  
                            if (event == AdmostAdEvent.loaded) {  
                              interstitialText = 'Show Interstitial';  
  setState(() {  
                                interstitialText;  
  });  
  }  
                            if (event == AdmostAdEvent.dismissed) {  
                              interstitialText = 'Load Interstitial';  
  setState(() {  
                                interstitialText;  
  });  
  }  
                            if (event == AdmostAdEvent.failedToLoad) {  
                              // Start hoping they didn't just ban your account :)  
  print("Error code: ${args['errorCode']}");  
  }  
                          },  
  );  
  }  
  
                      if (await interstitialAd.isLoaded) {  
                        interstitialAd.show();  
  } else {  
                        interstitialAd.load();  
  }  
                    },  
  child: Center(  
                      widthFactor: 2,  
  heightFactor: 2,  
  child: Text(interstitialText),  
  ),  
  ),  
  ),  
  Card(  
                  child: InkWell(  
                    splashColor: Colors.blue.withAlpha(30),  
  onTap: () async {  
                      if (rewardAd == null) {  
                        rewardAd = AdmostRewarded(  
                          zoneId: '88cfcfd0-2f8c-4aba-9f36-cc0ac99ab140',  
  listener: (AdmostAdEvent event,  
  Map<String, dynamic> args) {  
                            if (event == AdmostAdEvent.loaded) {  
                              rewardedText = 'Show Rewarded';  
  setState(() {  
                                rewardedText;  
  });  
  } else if (event == AdmostAdEvent.dismissed) {  
                              rewardedText = 'Load Rewarded';  
  setState(() {  
                                rewardedText;  
  });  
  } else if (event == AdmostAdEvent.failedToLoad) {  
                              // Start hoping they didn't just ban your account :)  
  print("Error code: ${args['errorCode']}");  
  } else if (event == AdmostAdEvent.completed) {  
                              print("REWARDED");  
  }  
                          },  
  );  
  }  
  
                      if (await rewardAd.isLoaded) {  
                        rewardAd.show();  
  } else {  
                        rewardAd.load();  
  }  
                    },  
  child: Center(  
                      widthFactor: 2,  
  heightFactor: 2,  
  child: Text(rewardedText),  
  ),  
  ),  
  ),  
  Card(  
                    child:  
                    AdmostBanner(  
                      adUnitId: "9fb970db-7d96-4ef2-ac8c-d88ec22270ff",  
  adSize: AdmostBannerSize.LEADERBOARD,  
  listener: (AdmostAdEvent event,  
  Map<String, dynamic> args) {  
                        if (event == AdmostAdEvent.loaded) {  
                          print("ADMOST Ad Loaded");  
  }  
                        if (event == AdmostAdEvent.clicked) {  
                          print("ADMOST Ad clicked");  
  }  
                        if (event == AdmostAdEvent.failedToLoad) {  
                          print("Error code: ${args['errorCode']}");  
  }  
                      },  
  )  
                )  
              ]  
          ),  
  
  ),  
  );  
  }  
  
}

Libraries

admost
admost_ad_events
admost_banner
admost_banner_controller
admost_banner_size
admost_event_handler
admost_interstitial
admost_rewarded