preloadWidgetAdView static method

Future<void> preloadWidgetAdView(
  1. String adUnitId,
  2. AdFormat adFormat, {
  3. String? placement,
  4. String? customData,
  5. Map<String, String?>? extraParameters,
  6. Map<String, dynamic>? localExtraParameters,
})

Preloads a MaxAdView platform widget for the specified adUnitId with the given adFormat before it is mounted in the widget tree.

When you mount a MaxAdView with the preloaded adUnitId, it will be constructed using the preloaded MaxAdView platform widget, allowing ads to be displayed more quickly. After unmounting the MaxAdView, the preloaded MaxAdView platform widget will not be destroyed; instead, it will be reused for the next mount. You must manually destroy it when it is no longer needed.

You can preload only one MaxAdView platform widget for a single Ad Unit ID. If you mount two MaxAdView widgets with the same Ad Unit ID, the first MaxAdView will use the preloaded platform widget, while the second MaxAdView will create its own platform widget and destroy it upon unmounting.

Returns a Future<void> that completes when the preload operation has been successfully started. If the preload operation fails to start, the Future completes with an error.

Implementation

static Future<void> preloadWidgetAdView(
  String adUnitId,
  AdFormat adFormat, {
  String? placement,
  String? customData,
  Map<String, String?>? extraParameters,
  Map<String, dynamic>? localExtraParameters,
}) {
  return _methodChannel.invokeMethod('preloadWidgetAdView', {
    'ad_unit_id': adUnitId,
    'ad_format': adFormat.value,
    'placement': placement,
    'custom_data': customData,
    'extra_parameters': extraParameters,
    'local_extra_parameters': localExtraParameters,
  });
}