adplayer_flutter_plugin 0.0.4
adplayer_flutter_plugin: ^0.0.4 copied to clipboard
A Flutter plugin for using the native AdPlayer SDK.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:adplayer_flutter_plugin/adplayer_flutter_plugin.dart';
import 'adPlayerPlacement.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
const String publisherId = "61cd5d774d31a9245f31f655";
const String tagId = "626e74718422076cea5b6bd7";
class _MyAppState extends State<MyApp> {
final _adPlayerFlutterPlugin = AdPlayerFlutterPlugin();
@override
void initState() {
super.initState();
initAdPlayerSdk(publisherId, tagId);
printAdPlayerVersion();
}
Future<void> initAdPlayerSdk(String publisherId, String tagId) async {
try {
await _adPlayerFlutterPlugin.initAdPlayerSdk(publisherId, tagId);
} on PlatformException {
// ignore: avoid_print
print('Failed to initialize AdPlayer SDK.');
}
}
Future<void> printAdPlayerVersion() async {
try {
final String? version = await _adPlayerFlutterPlugin.getAdPlayerVersion();
// ignore: avoid_print
print('AdPlayer version: $version');
} on PlatformException {
// ignore: avoid_print
print('Failed to get AdPlayer version.');
}
}
@override
Widget build(BuildContext context) {
return const AdPlayerPlacementView(tagId: tagId);
}
}