load method

Future<void> load()

don't forget to destroy after using it

Implementation

Future<void> load() async {
  assert(!_loaded);
  if (_loaded) return;
  _loaded = true;

  await InterstitialAdPlatformInterface.loadInterstitialAd(
    _id,
    placementId: placementId,
    listener: (result, args) {
      switch (result) {
        case InterstitialAdPlatformInterfaceResult.DISPLAYED:
          listener?.onDisplayed?.call();
          break;
        case InterstitialAdPlatformInterfaceResult.DISMISSED:
          listener?.onDismissed?.call();
          break;
        case InterstitialAdPlatformInterfaceResult.ERROR:
          final errorCode = args['error_code'];
          final errorMessage = args['error_message'];
          listener?.onError?.call(errorCode, errorMessage);
          break;
        case InterstitialAdPlatformInterfaceResult.LOADED:
          listener?.onLoaded?.call();
          break;
        case InterstitialAdPlatformInterfaceResult.CLICKED:
          listener?.onClicked?.call();
          break;
        case InterstitialAdPlatformInterfaceResult.LOGGING_IMPRESSION:
          listener?.onLoggingImpression?.call();
          break;
      }
    },
  );
}