I’m trying to display interstitial add on a button tap in my flutter based application, ad loaded as well but when I try to show it, it notifies the following callback onAdFailedToShowFullScreenContent and throws following error
error(code: 17, domain: com.google.admob, message: the provided view controller is not being presented.) site:stackoverflow.com
here is the code
this code opens up the showModalBottomSheet
void show() {
showModalBottomSheet(
context: context,
constraints: const BoxConstraints(
maxWidth: double.infinity,
),
builder: (context) {
return AudioConverter();
});
}
class _AudioConverterState extends State<AudioConverter> {
@override
Widget build(BuildContext context){
return Container(); // there is a button inside it, on the tap of that button, it calls the displayAd() function
}
}
displayAd function
void displayAd() async {
if (interstitialAd != null) {
interstitialAd!.fullScreenContentCallback =
FullScreenContentCallback(onAdDismissedFullScreenContent: (ad) {
convert();
}, onAdFailedToShowFullScreenContent: (ad, adError) {
print(adError); // the provided view controller is not being presented
});
interstitialAd!.show();
}
}