unity_ads_flutter 1.1.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 75

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

example/lib/main.dart

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 {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> with UnityAdsListener{

  UnityAdsError _error;
  String _errorMessage;
  bool _ready;

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

  @override
  Widget build(BuildContext context) {
    Widget body;
      if(_error!=null){
        body = new Center(
            child: new Text('$_error: $_errorMessage')
        );
      } else if(_ready){
        body=new Center(
            child:new RaisedButton(
                onPressed: () {
                  setState((){
                    _ready=false;
                  });
                  UnityAdsFlutter.show('video');
                },
                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,
      ),
    );
  }

  @override
  void onUnityAdsError(UnityAdsError error, String message) {
    print('$error occurred: $message');
    setState((){
      _error=error;
      _errorMessage=message;
    });
  }

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

  @override
  void onUnityAdsReady(String placementId) {
    print('Ready: $placementId');
    if (placementId == videoPlacementId){
      setState(() {
        _ready=true;
      });
    }
  }

  @override
  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:


dependencies:
  unity_ads_flutter: ^1.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages 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';
  
Version Uploaded Documentation Archive
1.1.0 Sep 4, 2018 Go to the documentation of unity_ads_flutter 1.1.0 Download unity_ads_flutter 1.1.0 archive
1.0.0 May 11, 2018 Go to the documentation of unity_ads_flutter 1.0.0 Download unity_ads_flutter 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
57
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
75
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6
  • Flutter: 0.11.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

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
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8