Skip to main content

Overview

Banner ads are rectangular ads displayed in a portion of the screen. They can be easily implemented using the AdropBannerView widget.

Key Features

  • Can be fixed at the top, bottom, or middle of the screen
  • Supports image and video ads
  • Handle ad events through callbacks
  • Provides ad metadata (creative ID, campaign ID, etc.)
Use the test unit ID for development: PUBLIC_TEST_UNIT_ID_320_100

AdropBannerView

Constructor

Parameters

Properties

Methods


Basic Usage


AdropBannerListener

A listener that handles banner ad events.

Callbacks

Callback Descriptions

Metadata

You can receive metadata in the onAdReceived, onAdClicked, and onAdImpression callbacks.
Creative size is accessed via bannerView.creativeSize?.width and bannerView.creativeSize?.height, not through metadata.

Ad Sizes

Banner ads require specifying container size according to the unit settings.

Common Banner Sizes

Fixed Size Usage

Fit to Screen Width

Size Configuration

You can explicitly set the banner view size using the adSize property.

Error Handling

Implement proper error handling when ad loading fails.

Best Practices

1. Release Resources

Always call dispose() when the banner view is no longer needed.

2. Refresh Ads

You can refresh ads as needed.

3. Conditional Rendering

Hide the banner area or show a placeholder until the ad loads.

4. Managing Multiple Banners

When using multiple banners, manage each state separately.

Complete Example


Backfill Ads

When backfill ads are enabled, backfill ads are automatically loaded when direct ads are unavailable. Backfill ad loading is handled automatically by the SDK. You can handle backfill-related errors using the backfillNoFill error code.
Banner ad metadata only includes the creativeId, txId, campaignId, destinationURL, and browserTarget fields. Backfill ads cannot be distinguished through metadata. You can detect backfill ad failures using the backfillNoFill error code.
To use backfill ads, add the backfill dependency to native platforms. See Getting Started.

Preloading Backfill Ads (preload)

Starting with SDK 1.17.0, you can use AdropBannerView.preload() to preload a backfill banner ad. When a banner that you load() with the same unit ID and the same size gets no direct ad and falls back to a backfill ad, it displays the preloaded ad right away instead of requesting a backfill ad again. load() still requests a direct ad first, regardless of preload. If a direct ad is displayed, the preloaded ad is kept as is. If you don’t call preload, the behavior is the same as before.

Requirements

  • You need adrop_ads_flutter 1.17.0 or later and, on the native platforms, the backfill dependency 1.17.0 or later. See Getting Started.
  • Preload fetches a backfill ad only when the server has told the app that there are no direct ads to show right now. Otherwise, it ends with ERROR_CODE_AD_PRELOAD_SKIPPED without requesting a backfill ad. This is a normal result in apps that have direct ad campaigns.
  • Right after the app is installed, right after you change the App Key, and right after you switch to a different user with setUID, preload ends with ERROR_CODE_AD_PRELOAD_SKIPPED until the server response arrives.
  • With test unit IDs, preload always ends with ERROR_CODE_AD_PRELOAD_SKIPPED.

Usage

Call preload right before you open the screen that contains the banner. A preloaded ad is discarded after 30 minutes if it isn’t used, so call preload only for banners you’re about to display. You don’t need to wait for the result before calling load(). If the ad is still being fetched, load() waits for that result and uses it. preload() completes when preloading succeeds. Any other result (including ERROR_CODE_AD_PRELOAD_SKIPPED) is delivered as a PlatformException whose code is the error code string. If you don’t handle it, even SKIPPED, which is a normal result, is reported as an unhandled asynchronous error, so wrap the call in try/catch or attach .catchError.
If you don’t need the result, you can call it like this.
To use the preloaded ad, set the adSize of the AdropBannerView you load() to the same size you passed to preload.

When a Preloaded Ad Is Used

  • Same unit ID and same size: The adSize of the AdropBannerView you load() must match the size you passed to preload. If the size differs, the preloaded ad is kept as is, and load() requests a backfill ad as usual.
  • Used only once: A preloaded ad is gone once a single load() uses it. To preload again, call preload again.
  • Lifetime and count: An ad that isn’t used within 30 minutes is discarded. Only 1 ad is kept per unit and size, and banners keep up to 5 different unit/size combinations. When there are more than 5, ads are discarded starting with the one received first.
  • Calling again: Calling preload again with the same unit and size doesn’t make a new request. If an ad has already been preloaded, the call completes without a new request; if one is still being fetched, the call gets that load’s result (success or failure). You can’t use preload to refresh an ad. However, if the user consent status has changed in the meantime, the existing ad is discarded and a new one is fetched.
  • Consent status changes: If the user consent status changes after an ad is preloaded, that ad isn’t used by load().
  • What completion means: When preload() completes, it means preloading has finished. A load() that was waiting for that result may have already used the ad.

Failure Codes

Don’t call preload again right away inside catch. If the result doesn’t change — for example, when the backfill dependency is missing — the calls repeat endlessly. Call it again later, such as before you open the next screen.

Next Steps

Native Ads

Implement customizable native ads that match your UI

Interstitial Ads

Implement full-screen interstitial ads

Popup Ads

Implement popup-style ads

Reference

View types, methods, and error codes