Adrop
The main class for the Adrop SDK. Handles SDK initialization and global settings.
Static Properties
| Property | Type | Description |
|---|
consentManager | AdropConsentManager | Consent manager for GDPR/CCPA consent management |
Static Methods
| Method | Description |
|---|
initialize(bool production, {List<String>? targetCountries, bool? useInAppBrowser}) | Initialize the SDK |
setUID(String uid) | Set user identifier (hashed with SHA-256) |
setTheme(AdropTheme theme) | Set ad theme |
registerWebView(int webViewIdentifier) | Register a WebView for backfill ad support |
Usage Example
import 'package:adrop_ads_flutter/adrop_ads_flutter.dart';
// Basic initialization (test mode)
await Adrop.initialize(false);
// Production mode + target country setting
await Adrop.initialize(
true,
targetCountries: ['KR', 'JP', 'US'],
);
// Set user ID
await Adrop.setUID('user123');
// Set theme
await Adrop.setTheme(AdropTheme.dark);
// Register WebView
import 'dart:io';
import 'package:webview_flutter_android/webview_flutter_android.dart';
import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart';
final int identifier;
if (Platform.isAndroid) {
identifier = (controller.platform as AndroidWebViewController).webViewIdentifier;
} else if (Platform.isIOS) {
identifier = (controller.platform as WebKitWebViewController).webViewIdentifier;
}
await Adrop.registerWebView(identifier);
AdropTheme
Enum for dark mode settings for ads.
Values
| Value | Description |
|---|
light | Light mode |
dark | Dark mode |
auto | Auto-follow system settings (default) |
Usage Example
await Adrop.setTheme(AdropTheme.dark);
AdropErrorCode
Error codes that can occur when loading and displaying ads.
Values
| Error Code | Code String | Description |
|---|
network | ERROR_CODE_NETWORK | Network error |
internal | ERROR_CODE_INTERNAL | Internal error |
initialize | ERROR_CODE_INITIALIZE | SDK initialization error |
invalidUnit | ERROR_CODE_INVALID_UNIT | Invalid ad unit ID |
notTargetCountry | ERROR_CODE_NOT_TARGET_COUNTRY | Not a target country |
inactive | ERROR_CODE_AD_INACTIVE | Deactivated ad |
adNoFill | ERROR_CODE_AD_NO_FILL | No available ads |
adLoadDuplicate | ERROR_CODE_AD_LOAD_DUPLICATED | Duplicate ad load request |
adLoading | ERROR_CODE_AD_LOADING | Ad loading in progress |
adEmpty | ERROR_CODE_AD_EMPTY | Ad is empty |
adShown | ERROR_CODE_AD_SHOWN | Ad already shown |
adHideForToday | ERROR_CODE_AD_HIDE_FOR_TODAY | Hide for today enabled |
accountUsageLimitExceeded | ERROR_CODE_ACCOUNT_USAGE_LIMIT_EXCEEDED | Account usage limit exceeded |
adLandscapeUnsupported | ERROR_CODE_LANDSCAPE_UNSUPPORTED | Landscape mode not supported |
backfillNoFill | ERROR_CODE_AD_BACKFILL_NO_FILL | No backfill ads available |
undefined | UNDEFINED | Undefined error |
Properties
| Property | Type | Description |
|---|
code | String | Error code string |
Factory Methods
| Method | Description |
|---|
AdropErrorCode.getByCode(String code) | Retrieve error code by code string |
AdropBannerView
Widget class for displaying banner ads.
Constructor
AdropBannerView({
required String unitId,
AdropBannerListener? listener,
})
Properties
| Property | Type | Description |
|---|
creativeSize | CreativeSize? | Creative size |
adSize | Size? | Banner view size setting |
Methods
| Method | Return Type | Description |
|---|
load() | Future<void> | Load ad |
dispose() | Future<void> | Release resources |
Usage Example
late AdropBannerView bannerView;
@override
void initState() {
super.initState();
bannerView = AdropBannerView(
unitId: 'YOUR_UNIT_ID',
listener: AdropBannerListener(
onAdReceived: (unitId, metadata) {
setState(() => isLoaded = true);
},
onAdFailedToReceive: (unitId, errorCode) {
debugPrint('Error: ${errorCode.code}');
},
),
);
bannerView.load();
}
@override
void dispose() {
bannerView.dispose();
super.dispose();
}
AdropBannerListener
Listener class for handling banner ad events.
Constructor
AdropBannerListener({
void Function(String unitId, Map<String, dynamic>? metadata)? onAdReceived,
void Function(String unitId, Map<String, dynamic>? metadata)? onAdClicked,
void Function(String unitId, Map<String, dynamic>? metadata)? onAdImpression,
void Function(String unitId, AdropErrorCode errorCode)? onAdFailedToReceive,
})
Callbacks
| Callback | Parameters | Description |
|---|
onAdReceived | unitId, metadata | Ad received successfully |
onAdClicked | unitId, metadata | Ad clicked |
onAdImpression | unitId, metadata | Ad impression |
onAdFailedToReceive | unitId, errorCode | Ad failed to receive |
| 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) |
AdropNativeAd
Class for requesting native ads.
Constructor
AdropNativeAd({
required String unitId,
bool useCustomClick = false,
AdropNativeListener? listener,
})
Properties
| Property | Type | Description |
|---|
isLoaded | bool | Whether ad is loaded |
unitId | String | Ad unit ID |
creativeId | String | Creative ID |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
destinationURL | String | Destination URL |
browserTarget | BrowserTarget? | How the destination URL opens (external/internal browser) |
properties | AdropNativeProperties | Native ad properties |
creativeSize | CreativeSize | Creative size |
isBackfilled | bool | Whether it is a backfilled ad |
Methods
| Method | Return Type | Description |
|---|
load() | Future<void> | Load ad |
Usage Example
final nativeAd = AdropNativeAd(
unitId: 'YOUR_UNIT_ID',
useCustomClick: true,
listener: AdropNativeListener(
onAdReceived: (ad) {
debugPrint('Ad received: ${ad.creativeId}');
},
onAdFailedToReceive: (ad, errorCode) {
debugPrint('Error: ${errorCode.code}');
},
),
);
await nativeAd.load();
AdropNativeAdView
Widget for displaying native ads on screen.
Constructor
AdropNativeAdView({
required AdropNativeAd? ad,
required Widget child,
})
Usage Example
AdropNativeAdView(
ad: nativeAd,
child: Container(
child: Column(
children: [
Text(nativeAd?.properties.headline ?? ''),
Text(nativeAd?.properties.body ?? ''),
],
),
),
)
AdropNativeListener
Listener class for handling native ad events.
Constructor
AdropNativeListener({
void Function(AdropNativeAd ad)? onAdReceived,
void Function(AdropNativeAd ad)? onAdClicked,
void Function(AdropNativeAd ad)? onAdImpression,
void Function(AdropNativeAd ad, AdropErrorCode errorCode)? onAdFailedToReceive,
})
Callbacks
| Callback | Parameters | Description |
|---|
onAdReceived | ad | Ad received successfully |
onAdClicked | ad | Ad clicked |
onAdImpression | ad | Ad impression |
onAdFailedToReceive | ad, errorCode | Ad failed to receive |
AdropNativeProperties
Content properties for native ads.
Properties
| Property | Type | Description |
|---|
headline | String? | Ad headline |
body | String? | Ad body |
creative | String? | HTML creative content |
asset | String? | Image asset URL |
destinationURL | String? | URL to navigate on click |
callToAction | String? | CTA button text |
profile | AdropNativeProfile? | Advertiser profile info |
extra | Map<String, String> | Additional custom fields |
isBackfilled | bool | Whether it is a backfilled ad |
AdropNativeProfile
Profile information for native ads.
Properties
| Property | Type | Description |
|---|
displayName | String? | Advertiser name |
displayLogo | String? | Advertiser logo image URL |
AdropInterstitialAd
Class for displaying interstitial ads.
Constructor
AdropInterstitialAd({
required String unitId,
AdropInterstitialListener? listener,
})
Properties
| Property | Type | Description |
|---|
isLoaded | bool | Whether ad is loaded |
unitId | String | Ad unit ID |
creativeId | String | Creative ID |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
destinationURL | String | Destination URL |
browserTarget | BrowserTarget? | How the destination URL opens (external/internal browser) |
Methods
| Method | Return Type | Description |
|---|
load() | Future<void> | Load ad |
show() | Future<void> | Show ad |
close() | Future<void> | Programmatically close the ad (Android only) |
dispose() | Future<void> | Release resources |
Usage Example
final interstitialAd = AdropInterstitialAd(
unitId: 'YOUR_UNIT_ID',
listener: AdropInterstitialListener(
onAdReceived: (ad) {
ad.show();
},
onAdFailedToReceive: (ad, errorCode) {
debugPrint('Error: ${errorCode.code}');
},
onAdDidDismissFullScreen: (ad) {
debugPrint('Ad dismissed');
},
),
);
await interstitialAd.load();
AdropInterstitialListener
Listener class for handling interstitial ad events.
Constructor
AdropInterstitialListener({
void Function(AdropAd ad)? onAdReceived,
void Function(AdropAd ad)? onAdClicked,
void Function(AdropAd ad)? onAdImpression,
void Function(AdropAd ad)? onAdWillPresentFullScreen,
void Function(AdropAd ad)? onAdDidPresentFullScreen,
void Function(AdropAd ad)? onAdWillDismissFullScreen,
void Function(AdropAd ad)? onAdDidDismissFullScreen,
void Function(AdropAd ad, AdropErrorCode errorCode)? onAdFailedToReceive,
void Function(AdropAd ad, AdropErrorCode errorCode)? onAdFailedToShowFullScreen,
void Function(AdropAd ad)? onAdBackButtonPressed,
})
Callbacks
| Callback | Description |
|---|
onAdReceived | Ad received successfully |
onAdClicked | Ad clicked |
onAdImpression | Ad impression |
onAdWillPresentFullScreen | Ad will present (iOS only) |
onAdDidPresentFullScreen | Ad presented |
onAdWillDismissFullScreen | Ad will dismiss (iOS only) |
onAdDidDismissFullScreen | Ad dismissed |
onAdFailedToReceive | Ad failed to receive |
onAdFailedToShowFullScreen | Ad failed to show |
onAdBackButtonPressed | Back button pressed while ad is displayed (Android only) |
AdropRewardedAd
Class for displaying rewarded ads.
Constructor
AdropRewardedAd({
required String unitId,
AdropRewardedListener? listener,
})
Properties
| Property | Type | Description |
|---|
isLoaded | bool | Whether ad is loaded |
unitId | String | Ad unit ID |
creativeId | String | Creative ID |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
destinationURL | String | Destination URL |
browserTarget | BrowserTarget? | How the destination URL opens (external/internal browser) |
serverSideVerificationOptions | ServerSideVerificationOptions? | Server-side verification options (userId, customData) |
Methods
| Method | Return Type | Description |
|---|
load() | Future<void> | Load ad |
show() | Future<void> | Show ad |
dispose() | Future<void> | Release resources |
Usage Example
final rewardedAd = AdropRewardedAd(
unitId: 'YOUR_UNIT_ID',
listener: AdropRewardedListener(
onAdReceived: (ad) {
ad.show();
},
onAdEarnRewardHandler: (ad, type, amount) {
// Grant reward
debugPrint('Reward: type=$type, amount=$amount');
},
),
);
await rewardedAd.load();
ServerSideVerificationOptions
Options for server-side verification (SSV) in rewarded ads. Set before calling load() to pass custom data to your server callback.
Constructor
const ServerSideVerificationOptions({
String? userId,
String? customData,
})
Properties
| Property | Type | Description |
|---|
userId | String? | User identifier for server-side verification |
customData | String? | Custom data string passed to the server callback |
Usage Example
final rewardedAd = AdropRewardedAd(
unitId: 'YOUR_UNIT_ID',
listener: AdropRewardedListener(
onAdEarnRewardHandler: (ad, type, amount) {
debugPrint('Reward: type=$type, amount=$amount');
},
),
);
// Set SSV options before loading
rewardedAd.serverSideVerificationOptions = ServerSideVerificationOptions(
userId: 'user_123',
customData: 'extra_data',
);
await rewardedAd.load();
AdropRewardedListener
Listener class for handling rewarded ad events.
Constructor
AdropRewardedListener({
void Function(AdropAd ad)? onAdReceived,
void Function(AdropAd ad)? onAdClicked,
void Function(AdropAd ad)? onAdImpression,
void Function(AdropAd ad)? onAdWillPresentFullScreen,
void Function(AdropAd ad)? onAdDidPresentFullScreen,
void Function(AdropAd ad)? onAdWillDismissFullScreen,
void Function(AdropAd ad)? onAdDidDismissFullScreen,
void Function(AdropAd ad, AdropErrorCode errorCode)? onAdFailedToReceive,
void Function(AdropAd ad, AdropErrorCode errorCode)? onAdFailedToShowFullScreen,
void Function(AdropAd ad, int type, int amount)? onAdEarnRewardHandler,
})
Callbacks
| Callback | Description |
|---|
onAdReceived | Ad received successfully |
onAdClicked | Ad clicked |
onAdImpression | Ad impression |
onAdWillPresentFullScreen | Ad will present (iOS only) |
onAdDidPresentFullScreen | Ad presented |
onAdWillDismissFullScreen | Ad will dismiss (iOS only) |
onAdDidDismissFullScreen | Ad dismissed |
onAdFailedToReceive | Ad failed to receive |
onAdFailedToShowFullScreen | Ad failed to show |
onAdEarnRewardHandler | Reward earned |
Class for displaying popup ads.
Constructor
AdropPopupAd({
required String unitId,
AdropPopupListener? listener,
Color? closeTextColor,
Color? hideForTodayTextColor,
Color? backgroundColor,
})
Properties
| Property | Type | Description |
|---|
isLoaded | bool | Whether ad is loaded |
unitId | String | Ad unit ID |
creativeId | String | Creative ID |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
destinationURL | String | Destination URL |
browserTarget | BrowserTarget? | How the destination URL opens (external/internal browser) |
closeTextColor | Color? | Close button text color |
hideForTodayTextColor | Color? | ”Hide for today” text color |
backgroundColor | Color? | Button background color |
Methods
| Method | Return Type | Description |
|---|
load() | Future<void> | Load ad |
show() | Future<void> | Show ad |
close() | Future<void> | Close ad |
dispose() | Future<void> | Release resources |
Usage Example
final popupAd = AdropPopupAd(
unitId: 'YOUR_UNIT_ID',
closeTextColor: Colors.white,
backgroundColor: Colors.black87,
listener: AdropPopupListener(
onAdReceived: (ad) {
ad.show();
},
),
);
await popupAd.load();
Listener class for handling popup ad events.
Constructor
AdropPopupListener({
void Function(AdropAd ad)? onAdReceived,
void Function(AdropAd ad)? onAdClicked,
void Function(AdropAd ad)? onAdImpression,
void Function(AdropAd ad)? onAdWillPresentFullScreen,
void Function(AdropAd ad)? onAdDidPresentFullScreen,
void Function(AdropAd ad)? onAdWillDismissFullScreen,
void Function(AdropAd ad)? onAdDidDismissFullScreen,
void Function(AdropAd ad, AdropErrorCode errorCode)? onAdFailedToReceive,
void Function(AdropAd ad, AdropErrorCode errorCode)? onAdFailedToShowFullScreen,
})
AdropMetrics
Class for managing user properties and events.
Static Methods
| Method | Return Type | Description |
|---|
setProperty(String key, dynamic value) | Future<void> | Set user property |
sendEvent(String name, [Map<String, dynamic>? params]) | Future<void> | Send event |
logEvent(String name, [dynamic params]) | Future<void> | Log event (deprecated, use sendEvent) |
properties() | Future<Map<String, dynamic>> | Get all properties |
Usage Example
import 'package:adrop_ads_flutter/adrop_ads_flutter.dart';
// Set properties
await AdropMetrics.setProperty('membership_level', 'premium');
await AdropMetrics.setProperty('age', 25);
await AdropMetrics.setProperty('is_subscriber', true);
// Remove property
await AdropMetrics.setProperty('membership_level', null);
// Send event
await AdropMetrics.sendEvent('purchase', {
'item_id': 'SKU_001',
'price': 29900,
});
// Get all properties
final props = await AdropMetrics.properties();
debugPrint('Properties: $props');
AdropConsentManager
Class for managing user consent (GDPR, CCPA, etc.). Access via Adrop.consentManager.
Methods
| Method | Return Type | Description |
|---|
requestConsentInfoUpdate(listener) | Future<void> | Request consent info update and show consent form if required |
getConsentStatus() | Future<AdropConsentStatus> | Get the current consent status |
canRequestAds() | Future<bool> | Check if ads can be requested |
setDebugSettings(AdropConsentDebugGeography geography) | Future<void> | Set debug geography for testing |
reset() | Future<void> | Reset consent information |
Usage Example
// Request consent
Adrop.consentManager.requestConsentInfoUpdate((result) {
debugPrint('Status: ${result.status}');
debugPrint('Can request ads: ${result.canRequestAds}');
});
// Check status independently
final status = await Adrop.consentManager.getConsentStatus();
final canRequest = await Adrop.consentManager.canRequestAds();
AdropConsentResult
Result object returned by the consent info update callback.
Properties
| Property | Type | Description |
|---|
status | AdropConsentStatus | Current consent status |
canRequestAds | bool | Whether ads can be requested |
canShowPersonalizedAds | bool | Whether personalized ads can be shown |
error | String? | Error message (null if no error) |
AdropConsentStatus
Enum representing the user’s consent status.
Values
| Value | Description |
|---|
unknown | Consent status not yet determined |
required | Consent required (popup will be shown) |
notRequired | Consent not required (non-GDPR region) |
obtained | Consent already obtained |
AdropConsentDebugGeography
Enum for testing consent flows with different geographies.
Values
| Value | Description |
|---|
disabled | Use actual device location |
eea | Test GDPR (European Economic Area) |
regulatedUSState | Test CCPA (California, etc.) |
other | Test non-regulated regions |
BrowserTarget
Enum controlling how destination URLs open when an ad is clicked.
Values
| Value | Description |
|---|
external | Opens in the system’s default browser |
internal | Opens in an in-app browser |
Usage Example
final ad = interstitialAd;
if (ad.browserTarget == BrowserTarget.internal) {
debugPrint('Ad will open in in-app browser');
}
CreativeSize
Class representing the size of a creative.
Constructor
const CreativeSize({
required double width,
required double height,
})
Properties
| Property | Type | Description |
|---|
width | double | Width |
height | double | Height |
AdropProperties
Enum for predefined user property keys used with AdropMetrics.setProperty.
Values
| Value | Code | Description |
|---|
age | AGE | User age |
birth | BIRTH | User birth date (yyyy, yyyyMM, yyyyMMdd format) |
gender | GDR | User gender (use AdropGender values) |
Usage Example
await AdropMetrics.setProperty(AdropProperties.age.code, 25);
await AdropMetrics.setProperty(AdropProperties.birth.code, '19900101');
await AdropMetrics.setProperty(AdropProperties.gender.code, AdropGender.male.code);
AdropGender
Enum for gender values used with AdropProperties.gender.
Values
| Value | Code | Description |
|---|
male | M | Male |
female | F | Female |
other | O | Other |
unknown | U | Unknown |
Deprecated Classes
The following classes are deprecated and will be removed in a future version.
| Deprecated Class | Migration | Notes |
|---|
AdropBanner | Use AdropBannerView | Banner ad widget. Replaced by AdropBannerView and AdropBannerListener |
AdropNavigatorObserver | Can be removed | No longer provides functionality and will be removed in a future version |
For more details on migration, see Getting Started.
Test Unit IDs
Unit IDs for development and testing.
| Format | Test Unit ID |
|---|
| Banner (320x50) | PUBLIC_TEST_UNIT_ID_320_50 |
| Banner (320x100) | PUBLIC_TEST_UNIT_ID_320_100 |
| Native | PUBLIC_TEST_UNIT_ID_NATIVE |
| Interstitial | PUBLIC_TEST_UNIT_ID_INTERSTITIAL |
| Rewarded | PUBLIC_TEST_UNIT_ID_REWARDED |
| Popup (Bottom) | PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM |
| Popup (Center) | PUBLIC_TEST_UNIT_ID_POPUP_CENTER |
| Splash | PUBLIC_TEST_UNIT_ID_SPLASH |
Make sure to replace with actual unit IDs before production deployment.
Getting Started
SDK installation and setup guide
Examples
Example code and sample projects