unity_ads_flutter 1.1.0

unity_ads_flutter #

Unity Ads for Flutter. This is an unofficial plugin based on the official Unity Ads plugins for Android and iOS.

Getting Started #

This plugin wraps the native Android and iOS APIs of Unity Ads. To learn more about the usage see the official Untiy Ads API Documentation for Android. Read CHANGELOG.md to see which versions of the native plugins are included.

[1.1.0] - 04.09.2018

Currently the following versions of the Unity Ads native plugins are used:

  • Android: 2.3.0
  • iOS: Nils told me that on iOS the newest version is used automatically

[1.0.0] - 11.05.2018

Currently the following versions of the Unity Ads native plugins are used:

  • Android: 2.2.1
  • iOS: 2.2.0


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

//TODO use your own ids from the Unity Ads Dashboard
const String videoPlacementId='video';
const String gameIdAndroid='1790451';
const String gameIdIOS='1790452';

void main() async {
  runApp(new MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => new _MyAppState();

class _MyAppState extends State<MyApp> with UnityAdsListener{

  UnityAdsError _error;
  String _errorMessage;
  bool _ready;

  initState() {
    UnityAdsFlutter.initialize(gameIdAndroid, gameIdIOS, this, true);
    _ready = false;

  Widget build(BuildContext context) {
    Widget body;
        body = new Center(
            child: new Text('$_error: $_errorMessage')
      } else if(_ready){
        body=new Center(
            child:new RaisedButton(
                onPressed: () {
                child: const Text('Ready')
      } else {
        body = new Center(
            child:const Text('Waiting for an ad...')
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Unity Ads Flutter Example'),
        body: body,

  void onUnityAdsError(UnityAdsError error, String message) {
    print('$error occurred: $message');

  void onUnityAdsFinish(String placementId, FinishState result) {
    print('Finished $placementId with $result');

  void onUnityAdsReady(String placementId) {
    print('Ready: $placementId');
    if (placementId == videoPlacementId){
      setState(() {

  void onUnityAdsStart(String placementId) {
    print('Start: $placementId');
    if(placementId == videoPlacementId){
      setState(() {
        _ready = false;

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  unity_ads_flutter: ^1.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:unity_ads_flutter/unity_ads_flutter.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health issues and suggestions

Document public APIs. (-1 points)

47 out of 47 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/unity_ads_flutter.dart.

Run flutter format to format lib/unity_ads_flutter.dart.

Maintenance suggestions

Package is getting outdated. (-46.58 points)

The package was last published 76 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8