Объявление загружается и успешно отображается в первый раз, но вызывает исключение при повторном вызове.
Это фрагмент кода, в котором создается межстраничное объявление -
InterstitialAd createInterstitialAd() {
return InterstitialAd(
adUnitId: InterstitialAd.testAdUnitId,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("InterstitialAd event $event");
},
);
}
Это фрагмент кода, в котором он вызывается -
if (!(await interstitialAd.isLoaded()))
interstitialAd = createInterstitialAd()..load();
interstitialAd.show();
interstitialAd?.dispose();
interstitialAd = createInterstitialAd()..load();
Тело ошибки -
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(no_ad_for_id, isAdLoaded failed, no add exists for id=444270692, null)
E/flutter (19241): #0 StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:569
E/flutter (19241): #1 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:156
E/flutter (19241): <asynchronous suspension>
E/flutter (19241): #2 MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:329
E/flutter (19241): #3 _invokeBooleanMethod
package:firebase_admob/firebase_admob.dart:611
E/flutter (19241): #4 MobileAd.isLoaded
package:firebase_admob/firebase_admob.dart:255
E/flutter (19241): #5 buildConsumer.<anonymous closure>.<anonymous closure>
package:compactimg/widgets/select_image_button.dart:56
E/flutter (19241): <asynchronous suspension>
E/flutter (19241): #6 buildConsumer.<anonymous closure>.<anonymous closure> (package:compactimg/widgets/select_image_button.dart)
E/flutter (19241): #7 _InkResponseState._handleTap
package:flutter/…/material/ink_well.dart:779
E/flutter (19241): #8 _InkResponseState.build.<anonymous closure>
package:flutter/…/material/ink_well.dart:862
E/flutter (19241): #9 GestureRecognizer.invokeCallback
package:flutter/…/gestures/recognizer.dart:182
E/flutter (19241): #10 TapGestureRecognizer.handleTapUp
package:flutter/…/gestures/tap.dart:504
E/flutter (19241): #11 BaseTapGestureRecognizer._checkUp
package:flutter/…/gestures/tap.dart:282
E/flutter (19241): #12 BaseTapGestureRecognizer.handlePrimaryPointer
package:flutter/…/gestures/tap.dart:217
E/flutter (19241): #13 PrimaryPointerGestureRecognizer.handleEvent
package:flutter/…/gestures/recognizer.dart:475
E/flutter (19241): #14 PointerRouter._dispatch
package:flutter/…/gestures/pointer_router.dart:76
E/flutter (19241): #15 PointerRouter._dispatchEventToRoutes.<anonymous closure>
package:flutter/…/gestures/pointer_router.dart:122
E/flutter (19241): #16 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter (19241): #17 PointerRouter._dispatchEventToRoutes