Overview
Banner ads are rectangular ads displayed in a portion of the screen. They can be easily implemented using theAdropBannerView 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_100AdropBannerView
Constructor
| Parameter | Type | Required | Description |
|---|---|---|---|
unitId | String | Y | Unit ID created in the Ad Control Console |
listener | AdropBannerListener | N | Ad event listener |
Properties
| Property | Type | Description |
|---|---|---|
creativeSize | CreativeSize? | Ad creative size |
adSize | Size? | Banner view size setting |
Methods
| Method | Return Type | Description |
|---|---|---|
load() | Future<void> | Loads the ad |
dispose() | Future<void> | Releases resources |
Basic Usage
AdropBannerListener
A listener that handles banner ad events.Callbacks
Callback Descriptions
| Callback | Description |
|---|---|
onAdReceived | Called when ad is received successfully |
onAdClicked | Called when ad is clicked |
onAdImpression | Called when ad is displayed |
onAdFailedToReceive | Called when ad fails to load |
onAdVideoStart | Called when video ad starts playing |
onAdVideoEnd | Called when video ad finishes playing |
Metadata
You can receive metadata in theonAdReceived, onAdClicked, and onAdImpression callbacks.
| Field | Type | Description |
|---|---|---|
creativeId | String | Creative ID |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
destinationURL | String | Destination URL |
browserTarget | int? | Browser target (0: external, 1: internal) |
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
| Size | Test Unit ID | Usage |
|---|---|---|
| 320 x 50 | PUBLIC_TEST_UNIT_ID_320_50 | Small banner |
| 320 x 100 | PUBLIC_TEST_UNIT_ID_320_100 | Medium banner |
Fixed Size Usage
Fit to Screen Width
Size Configuration
You can explicitly set the banner view size using theadSize property.
Error Handling
Implement proper error handling when ad loading fails.Best Practices
1. Release Resources
Always calldispose() 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 thebackfillNoFill 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.
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