adplayer_flutter_plugin 0.0.2 copy "adplayer_flutter_plugin: ^0.0.2" to clipboard
adplayer_flutter_plugin: ^0.0.2 copied to clipboard

unlistedoutdated

A Flutter plugin for using the native AdPlayer SDK.

adplayer_flutter_plugin #

A Flutter plugin for using the native AdPlayer SDK.

Getting Started #

Setup #

To gain access to the AdPlayer APIs, first obtain an instance of the AdPlayerFlutterPlugin:

import 'package:adplayer_flutter_plugin/adplayer_flutter_plugin.dart';

class _MyScreenState extends State<MyScreen> {
    final _adPlayerFlutterPlugin = AdPlayerFlutterPlugin();
}

Then init the AdPlayer SDK:

@override
void initState() {
    super.initState();
    await _adPlayerFlutterPlugin.initAdPlayerSdk(publisherId, tagId);
}

Display #

The player should be displayed via a platform view link inside an AspectRatio of 19 to 9 (1.78) with the tag ID in the creationParameters:

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';

@override
Widget build(BuildContext context) {

    const String viewType = 'AdPlayerPlacementView';
    const Map<String, dynamic> creationParams = <String, dynamic>{ "tagId": tagId };
    
    AspectRatio(
        aspectRatio: 1.78, // 16 to 9
        child: PlatformViewLink(
            viewType: viewType,
            surfaceFactory:
                (context, controller) {
                    return AndroidViewSurface(
                        controller: controller as AndroidViewController,
                        gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
                        hitTestBehavior: PlatformViewHitTestBehavior.opaque,
                    );
                },
            onCreatePlatformView: (params) {
                return PlatformViewsService.initSurfaceAndroidView(
                    id: params.id,
                    viewType: viewType,
                    layoutDirection: TextDirection.ltr,
                    creationParams: creationParams,
                    creationParamsCodec: const StandardMessageCodec(),
                    onFocus: () {
                        params.onFocusChanged(true);
                    },
                )
                ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
                ..create();
            },
        )
    )
}
0
likes
0
points
80
downloads

Publisher

verified publisheradservrs.com

Weekly Downloads

A Flutter plugin for using the native AdPlayer SDK.

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on adplayer_flutter_plugin

Packages that implement adplayer_flutter_plugin