Displaying A Player - Flutter
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 initialize the AdPlayer SDK:
@override
void initState() {
super.initState();
await _adPlayerFlutterPlugin.initAdPlayerSdk(publisherId, tagId);
}
Display
To display a player just present an AdPlayerPlacementWidget
as part of your UI:
import 'package:adplayer_flutter_plugin/adPlayerPlacement.dart';
@override
Widget build(BuildContext context) {
return AdPlayerPlacementWidget(tagId: tagId);
}
Make sure the value of tagId
is the same one that is being passed to initAdPlayerSdk
.