flutter_mopub 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 75

flutter_mopub #

Gitlab pipeline status

A new Flutter plugin that uses native platform views to show mopub rewarded video ads!

Installation #

  1. Depend on it Add this to your package's pubspec.yaml file:
dependencies:
  flutter_mopub: ^0.0.1

  1. 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.

  1. Import it Now in your Dart code, you can use:
import 'package:flutter_mopub/flutter_mopub.dart';

Supported Platforms #

  • 0.2.0 >= AndroidX

Supported MoPub features #

  • Rewarded Video Ads

Android integration #

  • Change minimum sdk to 19 :
  1. Open app level build.gradle file (android/app/build.gradle)
  2. In android->defaultConfig scope change this line
defaultConfig {
        .
        .
        .
        minSdkVersion 19 //default is 16
        .
        .
        .
        multiDexEnabled true //add this line if you have build errors
    }
  • In dependencies scope add this line (to resolve conflict between packages. apply only if you face build errors)
dependencies {
        .
        .
        .
        implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava' //add this line
        .
        .
        .
    }

View the rest of the documentation on the example tab. #

[0.0.1] - April 2020 #

  • Release first version

example/lib/main.dart

import 'dart:async';

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

void main() {
  FlutterMopub.initilize(adUnitId: FlutterMopub.testAdUnitId)
      .then((didInitilize) {
    if (didInitilize) {
      runApp(MyApp());
    } else {
      print('Mopub plugin initilize error');
    }
  });
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  RewardedVideoAdEvent _event;
  @override
  void initState() {
    super.initState();
    loadAndShowAd();
  }

  Future<void> loadAndShowAd() async {
    //Add listener to catch events
    FlutterMopub.rewardedVideoAdInstance.setRewardedVideoListener(
        listener: (event, args) {
      setState(() {
        _event = event;
      });
      if (event == RewardedVideoAdEvent.SUCCESS) {
        //ad is loaded now show the add
        FlutterMopub.rewardedVideoAdInstance
            .show(adUnitId: FlutterMopub.testAdUnitId);
      }
    });

    //load ad
    int loadOutcome = await FlutterMopub.rewardedVideoAdInstance
        .load(adUnitId: FlutterMopub.testAdUnitId);
    if (loadOutcome >= 0) {
      //successfully added Ad to loading queue
      print('ad is in loading queue');
    } else {
      //failed to add Ad to loading queue
      print('failed to load ad : errCode = $loadOutcome');
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('MoPub example app'),
        ),
        body: Center(
          child: Text('Ad Status: $_event'),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_mopub: ^0.0.1

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:flutter_mopub/flutter_mopub.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
55
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
75
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:flutter_mopub/flutter_mopub.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:flutter_mopub/flutter_mopub.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:flutter_mopub/flutter_mopub.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:flutter_mopub/flutter_mopub.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • flutter_mopub that is a package requiring null.

Health suggestions

Fix lib/flutter_mopub.dart. (-0.50 points)

Analysis of lib/flutter_mopub.dart reported 1 hint:

line 62 col 24: This function has a return type of 'RewardedVideoAdEvent', but doesn't end with a return statement.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test