The following sections show you how to load and then show and hide a banner or MREC ad.
Loading a Banner or MREC
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:
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, MaxAdView is constructed 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.
When you unmount the MaxAdView, the preloaded platform widget is not destroyed.
Instead, it is cached and reused for the next mount.
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.
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: