Reputation: 129
I am trying to show an Unity Ad when a button is pressed. I tried a few things but I can't fix it.
Here are my code snippets:
main.dart ->
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () async {
await AdManager.showIntAd();
},
child: Text('Doniraj'),
)),),
AdManager.dart ->
static Future<void> showIntAd() async {
UnityAds.showVideoAd(
placementId: AdHelper.interstitialId,
onStart: (placementId) => print('Video Ad $placementId started'),
onClick: (placementId) => print('Video Ad $placementId click'),
onSkipped: (placementId) => print('Video Ad $placementId skipped'),
onComplete: (placementId) async {
await loadUnityIntAd();
},
onFailed: (placementId, error, message) async {
await loadUnityIntAd();
});
}
I appreciate your suggestions
Upvotes: 0
Views: 325