If you need to adjust your UI based on the adaptive banner size, you can retrieve the width and height of the loaded ad, in dp. The following code demonstrates how to do this:
You may want to stop auto-refresh for an ad. This may be the case when you hide an ad or when you want to manually refresh. Stop auto-refresh with the following code:
Start auto-refresh for an ad with the following code:
Banner and MREC ads are rectangular ad formats that occupy part of an app’s layout—often at the top or bottom of the screen or inline in scrollable content. They remain visible as users interact with the app, which allows uninterrupted gameplay or use, and can refresh automatically after a set period.
The following sections show you how to load, show, and hide a banner or MREC ad.
The following code shows you how to load a banner or MREC by using your Ad Unit ID, desired position, and (for banners) desired background color. MAX will size the ad for you automatically:
To show a banner or MREC, make the following call:
To hide a banner or MREC, make the following call:
You can also render a banner or MREC directly in your widget tree:
As of Flutter plugin version 3.11.1, you can preload ads for platform widgets before you mount MaxAdView.
When you mount MaxAdView with the Ad Unit ID you preloaded, this constructs MaxAdView with a preloaded platform widget.
This allows the ads to display quickly.
Flutter plugin version 4.1.0 updates this preloading feature to support multiple MaxAdView instances.
The preloadWidgetAdView() method returns an AdViewId, which you can use to specify the preloaded ad when you mount a MaxAdView.
You can specify the AdViewId when you mount a MaxAdView:
When you unmount the MaxAdView, this does not destroy the preloaded platform widget, but caches it so the next mount can reuse it.
To release its resources, you must manually destroy it when you no longer need it:
If you omit an AdViewId when you mount a MaxAdView, the component dynamically loads an ad.
In such a case, when you unmount the MaxAdView, it is automatically destroyed and cannot be reused.
See the example app at the AppLovin-MAX-Flutter GitHub project for a complete working example.
{/** NOT SURE THIS HAS BEEN FULLY IMPLEMENTED YET
To manually set a banner’s width, call setBannerWidth():
Set the banner width to a size larger than the minimum value (320 on phones, 728 on tablets). The advertiser may consider banners under this width to be not-viewable, which affects your revenue. If you set the banner width below the minimum, you will see an error message in your logs. For example:
**/}
Adaptive banners are responsive banners with heights that derive from the device type and the width of the banner.
Starting with Flutter plugin version 4.2.0, banners from ad networks that support adaptive banners are adaptive by default.
To disable adaptive banners, set the corresponding parameter to false as in the following examples:
“Why mobile banners ads persist in a video and playable world” from AppLovin’s Blog.
Google bidding and Google AdMob, Google Ad Manager, Liftoff Monetize, Pangle, and Yandex support adaptive banners. MAX sizes banners from other networks in the non-adaptive way.
Google recommends that developers include a 50 px padding between the banner placement and the app content. This makes it less likely that users accidentally click the banner. Refer to Google’s “About Confirmed Click” policy for more information and best practices.