flutter_xy_plugin 1.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 55

flutter_xy_plugin #

Flutter plugin for Adtalos SDK, supporting banner, native, interstitial (full-screen/half-screen), splash and rewarded video ads using the Adtalos SDK Android API and iOS API.

Setup #

iOS #

To use this plugin on iOS you need to opt-in for the embedded views preview by adding a boolean property to the app's Info.plist file, with the key io.flutter.embedded_views_preview and the value YES.

Usage #

Add flutter_xy_plugin as a dependency in your pubspec.yaml file.

Using Banner and Native ads #

Banner ad example:

XyView(id : "209A03F87BA3B4EB82BEC9E5F8B41383");

Another banner ad example:

XyView(
  onCreated: (view) {
    view.load("209A03F87BA3B4EB82BEC9E5F8B41383");
  },
  onLoaded: (view) {
    view.show();
  },
  onImpressionFinished: (view) {
    print("onImpressionFinished");
  },
)

Native ad example:

XyView(
  id: "98738D91D3BB241458D3FAE5A5BF7B34",
  size: Size.NATIVE,
  carousel: false,
)

Another native ad example:

XyView(
  size: Size.NATIVE,
  carousel: false,
  onCreated: (view) {
    view.load("98738D91D3BB241458D3FAE5A5BF7B34");
  },
  onLoaded: (view) {
    view.show();
  },
  onImpressionFinished: (view) {
    print("onImpressionFinished");
  },  
)

Note: if you used XyView as a child of SingleChildScrollView, you need wrap XyView in a Container with specified height.

Using Splash, Interstitial and Rewarded video ads #

Splash ad example:

XyController(
  "5C3DD65A809B08A2D6CF3DEFBC7E09C7",
  type: Type.Splash,
  onCreated: (controller) {
    controller.load();
  },
  onLoaded: (controller) {
    controller.show();
  },
);

Note: You need to add the above code into the initState method of your AppState.

Interstitial ad example:

XyController(
  "2EF810225D10260506CBB704C96C5325",
  type: Type.Interstitial,
  onCreated: (controller) {
    controller.load();
  },
  onLoaded: (controller) {
    controller.show();
  },
);

Rewarded video ad example:

XyController(
  "527E187C5DEA600C35309759469ADAA8",
  type: Type.RewardedVideo,
  onCreated: (controller) {
    controller.load();
  },
  onLoaded: (controller) {
    controller.show();
  },
);

Note: XyController is not a widget. You can not include an XyController in the widget tree.

Events #

Both XyView and XyController support the following events:

  • onCreated
  • onCustom
  • onRendered
  • onImpressionFinished
  • onImpressionFailed
  • onImpressionReceivedError
  • onLoaded
  • onFailedToLoad
  • onOpened
  • onClicked
  • onLeftApplication
  • onClosed
  • onVideoLoad
  • onVideoStart
  • onVideoPlay
  • onVideoPause
  • onVideoEnd
  • onVideoVolumeChange
  • onVideoTimeUpdate
  • onVideoError
  • onVideoBreak

In addition, XyView supports onViewClose event.

1.1.0 #

  • Upgrade to AndroidX.

1.0.0 #

  • Remove getter landingPageDisplayActionBarEnabled.
  • Remove getter landingPageAnimationEnabled.
  • Remove getter landingPageFullScreenEnabled.

0.3.0 #

  • Update XY iOS SDK to 1.4.3.

0.2.0 #

  • Update XY Android SDK to 2.2.2.

0.1.0 #

  • Initial release.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_xy_plugin/flutter_xy_plugin.dart';
import 'package:flutter_msa_sdk/flutter_msa_sdk.dart';

void main() => runApp(MyApp());

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

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    if (await FlutterMsaSdk.isSupport()) {
      FlutterXyPlugin.oaid = await FlutterMsaSdk.getOAID();
    }
    XyController(
      "5C3DD65A809B08A2D6CF3DEFBC7E09C7",
      type: Type.Splash,
      onCreated: (controller) {
        controller.load();
      },
      onLoaded: (controller) {
        controller.show();
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('新义互联广告 SDK Flutter 插件演示'),
        ),
        body: SingleChildScrollView(
          child: Center(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                Container(
                    height: 80,
                    child: XyView(
//                      id : "209A03F87BA3B4EB82BEC9E5F8B41383",
                      onCreated: (view) {
                        view.load("209A03F87BA3B4EB82BEC9E5F8B41383");
                      },
                      onLoaded: (view) {
                        view.show();
                      },
                      onImpressionFinished: (view) {
                        print(
                            "onImpressionFinished: 209A03F87BA3B4EB82BEC9E5F8B41383");
                      },
                    )),
                Container(
                    height: 300,
                    child: XyView(
                      id: "98738D91D3BB241458D3FAE5A5BF7B34",
                      size: Size.NATIVE,
                      carousel: false,
//                      onCreated: (view) {
//                        view.load("98738D91D3BB241458D3FAE5A5BF7B34");
//                      },
//                      onLoaded: (view) {
//                        view.show();
//                      },
                      onImpressionFinished: (view) {
                        print(
                            "onImpressionFinished: 98738D91D3BB241458D3FAE5A5BF7B34");
                      },
                    )),
                RaisedButton(
                    child: const Text('Show Interstitial Ad'),
                    onPressed: () {
                      XyController(
                        "2EF810225D10260506CBB704C96C5325",
                        type: Type.Interstitial,
                        onCreated: (controller) {
                          controller.load();
                        },
                        onLoaded: (controller) {
                          controller.show();
                        },
                      );
                    }),
                RaisedButton(
                    child: const Text('Show RewardedVideo Ad'),
                    onPressed: () {
                      XyController(
                        "527E187C5DEA600C35309759469ADAA8",
                        type: Type.RewardedVideo,
                        onCreated: (controller) {
                          controller.load();
                        },
                        onLoaded: (controller) {
                          controller.show();
                        },
                      );
                    }),
              ].map((Widget button) {
                return Padding(
                  padding: const EdgeInsets.symmetric(vertical: 16.0),
                  child: button,
                );
              }).toList(),
            ),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.8.2
  • pana: 0.13.8-dev
  • Flutter: 1.17.1

Health issues and suggestions

Document public APIs. (-0.38 points)

93 out of 95 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.

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
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test