preloadWidgetAdView static method
Preloads a MaxAdView platform widget for the specified adUnitId and adFormat.
Preloading a MaxAdView improves ad rendering speed when the widget is later
mounted in the widget tree. The preloaded platform widget is reused across
mounts for the same adViewId until explicitly destroyed, reducing load times.
-
Behavior:
- When a MaxAdView is mounted with the preloaded
adViewId, it uses the preloaded platform widget for faster rendering.
- When a MaxAdView is mounted with the preloaded
-
Important: Preloaded platform widgets must be destroyed manually using destroyWidgetAdView when they are no longer needed to free up resources.
-
Return: A
Future<AdViewId?>that completes once the preload operation starts. If the operation fails, the future completes with an error.
Implementation
static Future<AdViewId?> preloadWidgetAdView(
String adUnitId,
AdFormat adFormat, {
String? placement,
String? customData,
Map<String, String?>? extraParameters,
Map<String, dynamic>? localExtraParameters,
}) {
Map<String, String?> extraParametersWithAdaptiveBanner = Map<String, String?>.from(extraParameters ?? {});
if (extraParameters?['adaptive_banner'] == null) {
// Set the default value for 'adaptive_banner'
extraParametersWithAdaptiveBanner['adaptive_banner'] = 'true';
}
return _methodChannel.invokeMethod('preloadWidgetAdView', {
'ad_unit_id': adUnitId,
'ad_format': adFormat.value,
'placement': placement,
'custom_data': customData,
'extra_parameters': extraParametersWithAdaptiveBanner,
'local_extra_parameters': localExtraParameters,
});
}