Reputation: 553
I'm trying to display interstitial ad after user pick the image/video from the gallery but as soon as image is picked and I try to display ad, it throws the following error
The provided view controller is already presenting another view controller
void pickFromGallery() async {
ImagePicker imagePicker = ImagePicker();
XFile? pickedVideo =
await imagePicker.pickVideo(source: ImageSource.gallery);
if (pickedVideo != null) {
initialise(pickedVideo.path);
}
}
void initialise(String path) async {
if (interstitialAd != null) {
interstitialAd!.fullScreenContentCallback = FullScreenContentCallback(
onAdDismissedFullScreenContent: (ad) {},
onAdFailedToShowFullScreenContent: (ad, adError) {
print(adError); // The provided view controller is already presenting another view controller
});
await interstitialAd!.show();
} else {
show(pickedVideo: File(path));
}
}
it invokes the onAdFailedToShowFullScreenContent callback and throws the error
Upvotes: 2
Views: 26