---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://ads.yandex.com/helpcenter/en/dev/flutter/release/6-0-0-migration.md
  - https://ads.yandex.com/helpcenter/ru/dev/flutter/release/6-0-0-migration.md
  - https://ads.yandex.com/helpcenter/zh/dev/flutter/release/6-0-0-migration.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ads.yandex.com/helpcenter/en/llms.txt

# Guide for migrating to version 6

{% note warning %}

Make sure to update your used [Yandex Mediation](https://ads.yandex.com/helpcenter/en/dev/flutter/list-network.md) adapters to the latest version. Older versions may cause adapter integration errors that can prevent your ads from being served.

{% endnote %}

## Banners

Renamed the `AdSize` class to `BannerAdSize`. Removed the `FlexibleSize(int width, int height)` method.

Use methods depending on the ad type:

Use the `BannerAdSize.stickySize(int width)` method to create an adaptive sticky banner.

> That is a small, automatically updated ad placed at the top or bottom of the app screen.
>
> It does not overlap the main app content and is often used in game apps.
>
> The height of a sticky banner is determined automatically, adapting to the screen size of the device and not taking up more than 15% of the screen height.

{% note warning %}

Version 6.0.0 added autorefresh support for adaptive sticky banners.

If you have previously implemented autorefresh for sticky banners, disable it.

{% endnote %}

Use the `BannerAdSize.inlineSize(int width, int maxHeight) method` to create an adaptive inline banner.

> Adaptive inline banners are a flexible format of banner advertising, providing maximum efficiency by optimizing the ad size on each device.
>
> The height of the banner is adjusted automatically and might reach the device screen height.
>
> Typically, that format is used in feed-based apps or contexts where it's okay to focus primarily on the ad.

## Rewarded ads

We changed the approach to creating and loading ads. We now provide the `RewardedAdLoader` loader object, which loads the ads, and the `RewardedAd` ad object retrieved from the `OnAdLoaded` ad load event.

#|
||
Ad loading
| **SDK 5**

A single object for ad loading and rendering:

```dart
final ad = await RewardedAd.create(
  adUnitId: 'your-ad-unit-id',
  onAdLoaded: () {
    /* Do something */
  },
  onAdFailedToLoad: (error) {
      /* Do something */
  },
);
await ad.load(adRequest: AdRequest());
```

**SDK 6**

`RewardedAdLoader` for loading multiple ads:

```dart
late final Future<RewardedAdLoader> _adLoader =
      _createRewardedAdLoader();
RewardedAd? _ad;

Future<RewardedAdLoader> _createRewardedAdLoader() {
  return RewardedAdLoader.create(
    onAdLoaded: (RewardedAd rewardedAd) {
      // The ad was loaded successfully. Now you can show loaded ad
      _ad = rewardedAd;
    },
    onAdFailedToLoad: (error) {
      // Ad failed to load with AdRequestError.
      // Attempting to load a new ad from the onAdFailedToLoad() method is strongly discouraged.
    },
  );
}

Future<void> _loadRewardedAd() async {
  final adLoader = await _adLoader;
  await adLoader.loadAd(adRequestConfiguration: AdRequestConfiguration(adUnitId: 'your-ad-unit-id'));
}
```

||
||
Ad rendering
| **SDK 5**

Before showing the ad, see if it loaded.

```dart
RewardedAd? _ad;

Future<void> _showRewardedAd() async {
  final ad = _ad;
  if (ad != null && ad.isLoaded) {
    await ad.show();
    var reward = await ad.waitForDismiss();
  }
}
```

**SDK 6**

You don't need to check to see if the ad is loaded. The ad is ready for rendering after it is returned by the `onAdLoaded()` callback method.

```dart
RewardedAd? _ad;

Future<void> _showRewardedAd() async {
  final ad = _ad;
  if (ad != null) {
    _setAdEventListener(ad);
    await ad.show();
    var reward = await ad.waitForDismiss();
  }
}
```

||
||
Subscribing to ad lifecycle events
| **SDK 5**

All the events arrive in a single `RewardedAd` object.

```dart
RewardedAd.create(
  onAdLoaded: () {},
  onAdFailedToLoad: (AdLoadError error) {},
  onAdShown: () {},
  onAdDismissed: () {},
  onRewarded: (Reward reward) {},
  onAdClicked: () {},
  onLeftApplication: () {},
  onReturnedToApplication: () {},
  onImpression: (String? impressionData) {},
);
```

**SDK 6**

Ad loading events arrive in the `RewardedAdLoader` object, while ad rendering events arrive in the `RewardedAdEventListener` object.

The `RewardedAdEventListener` object is set using the `rewardedAd.setAdEventListener` method.

Unified the event names. Removed the `OnLeftApplication` and `OnReturnedToApplication` events.

Added the `onAdFailedToShow` event.

Renamed the `onImpression` event as `onAdImpression`.

```dart
RewardedAdLoader.create(
  onAdLoaded: (RewardedAd rewardedAd) {},
  onAdFailedToLoad: (error) {},
);

void _setAdEventListener(RewardedAd ad) {
  ad.setAdEventListener(
      eventListener: RewardedAdEventListener(
          onAdShown: () {},
          onAdFailedToShow: (AdError error) {},
          onAdDismissed: () {},
          onAdClicked: () {},
          onAdImpression: (ImpressionData? data) {},
          onRewarded: (Reward reward) {}
      )
  );
}
```

||
|#

## Interstitial advertising

We changed the approach to creating and loading ads. We now provide the `InterstitialAdLoader` loader object, which loads the ads, and the `Interstitial` ad object retrieved from the `OnAdLoaded` ad load event.

#|
||
Ad loading
| **SDK 5**

A single object for ad loading and rendering:

```dart
final ad = await InterstitialAd.create(
  adUnitId: 'your-ad-unit-id',
  onAdLoaded: () {
    /* Do something */
  },
  onAdFailedToLoad: (error) {
      /* Do something */
  },
);
await ad.load(adRequest: AdRequest());
```

**SDK 6**

`InterstitialAdLoader` for loading multiple ads.

```dart
late final Future<InterstitialAdLoader> _adLoader =
      _createInterstitialAdLoader();
InterstitialAd? _ad;

Future<InterstitialAdLoader> _createInterstitialAdLoader() {
  return InterstitialAdLoader.create(
    onAdLoaded: (InterstitialAd interstitialAd) {
      // The ad was loaded successfully. Now you can show loaded ad
      _ad = interstitialAd;
    },
    onAdFailedToLoad: (error) {
      // Ad failed to load with AdRequestError.
      // Attempting to load a new ad from the onAdFailedToLoad() method is strongly discouraged.
    },
  );
}

Future<void> _loadInterstitialAd() async {
  final adLoader = await _adLoader;
  await adLoader.loadAd(adRequestConfiguration: AdRequestConfiguration(adUnitId: 'your-ad-unit-id'));
}
```

||
||
Ad rendering
| **SDK 5**

Before showing the ad, see if it loaded.

```dart
InterstitialAd? _ad;

Future<void> _showInterstitialAd() async {
  final ad = _ad;
  if (ad != null && ad.isLoaded) {
    await ad.show();
    await ad.waitForDismiss();
  }
}
```

**SDK 6**

You don't need to check to see if the ad is loaded. The ad is ready for rendering after it is returned by the `onAdLoaded()` callback method.

```dart
InterstitialAd? _ad;

Future<void> _showInterstitialAd() async {
  final ad = _ad;
  if (ad != null) {
    _setAdEventListener(ad);
    await ad.show();
    await ad.waitForDismiss();
  }
}
```

||
||
Subscribing to ad lifecycle events
| **SDK 5**

All the events arrive in a single `InterstitialAd` object.

```dart
InterstitialAd.create(
  onAdLoaded: () {},
  onAdFailedToLoad: (AdLoadError error) {},
  onAdShown: () {},
  onAdDismissed: () {},
  onAdClicked: () {},
  onLeftApplication: () {},
  onReturnedToApplication: () {},
  onImpression: (String? impressionData) {},
);
```

**SDK 6**

Ad loading events arrive in the `InterstitialAdLoader` object, while ad rendering events arrive in the `InterstitialAdEventListener` object.

The `InterstitialAdEventListener` object is set using the `interstitialAd.setAdEventListener` method.

Unified the event names. Removed the `OnLeftApplication` and `OnReturnedToApplication` events.

Added the `onAdFailedToShow` event.

Renamed the `onImpression` event as `onAdImpression`.

```dart
InterstitialAdLoader.create(
  onAdLoaded: (InterstitialAd interstitialAd) {},
  onAdFailedToLoad: (error) {},
);

void _setAdEventListener(InterstitialAd ad) {
  ad.setAdEventListener(
      eventListener: InterstitialAdEventListener(
          onAdShown: () {},
          onAdFailedToShow: (AdError error) {},
          onAdDismissed: () {},
          onAdClicked: () {},
          onAdImpression: (ImpressionData? data) {}
      )
  );
}
```

||
|#

## App open ad

Added a new ad format: app open ad. To learn more, see [App open ads](https://ads.yandex.com/helpcenter/en/dev/flutter/app-open-ad.md)

Here you can find the complete examples for integrations:

* <!-- source: en/dev/_includes/github-pubdev-links.md -->
  Link to [pub.dev](https://pub.dev/packages/yandex_mobileads/example).
  <!-- endsource: en/dev/_includes/github-pubdev-links.md -->

* <!-- source: en/dev/_includes/github-pubdev-links.md -->
  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-flutter-plugin).
  <!-- endsource: en/dev/_includes/github-pubdev-links.md -->

## Yandex Mediation

{% note warning %}

Make sure to update your used [Yandex Mediation](https://ads.yandex.com/helpcenter/en/dev/flutter/list-network.md) adapters to the latest version. Older versions may cause adapter integration errors that can prevent your ads from being served.

{% endnote %}

{% list tabs %}

- Android

   Renamed the `com.yandex.ads.mediation:mobileads-admob` artifact as `com.yandex.ads.mediation:mobileads-google`.

   If you use the standardized mediation build, you don't have to do anything. If you add adapters individually, replace the gradle dependency in your project.

   #|
   || **SDK 5**
   ```gradle
   implementation 'com.yandex.ads.mediation:mobileads-admob:<version>'
   ```
   | **SDK 6**
   ```gradle
   implementation 'com.yandex.ads.mediation:mobileads-google:<version>'
   ```
   ||
   |#

- iOS

   We renamed the `AdMobYandexMobileAdsAdapters`  adapters as `GoogleYandexMobileAdsAdapters`. If you use the standardized mediation build, you don't have to do anything. If you add adapters individually, you need to edit your project's Podfile.

   #|
   || **SDK 5**
   ```bash
   pod 'AdMobYandexMobileAdsAdapters'
   ```
   | **SDK 6**
   ```bash
   pod 'GoogleYandexMobileAdsAdapters'
   ```
   ||
   |#

{% endlist %}
