Skip to main content

Adrop

The main class for the Adrop SDK. Handles SDK initialization and global settings.

Static Properties

PropertyTypeDescription
consentManagerAdropConsentManagerConsent manager for GDPR/CCPA consent management

Static Methods

MethodDescription
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

ValueDescription
lightLight mode
darkDark mode
autoAuto-follow system settings (default)

Usage Example

await Adrop.setTheme(AdropTheme.dark);

AdropErrorCode

Error codes that can occur when loading and displaying ads.

Values

Error CodeCode StringDescription
networkERROR_CODE_NETWORKNetwork error
internalERROR_CODE_INTERNALInternal error
initializeERROR_CODE_INITIALIZESDK initialization error
invalidUnitERROR_CODE_INVALID_UNITInvalid ad unit ID
notTargetCountryERROR_CODE_NOT_TARGET_COUNTRYNot a target country
inactiveERROR_CODE_AD_INACTIVEDeactivated ad
adNoFillERROR_CODE_AD_NO_FILLNo available ads
adLoadDuplicateERROR_CODE_AD_LOAD_DUPLICATEDDuplicate ad load request
adLoadingERROR_CODE_AD_LOADINGAd loading in progress
adEmptyERROR_CODE_AD_EMPTYAd is empty
adShownERROR_CODE_AD_SHOWNAd already shown
adHideForTodayERROR_CODE_AD_HIDE_FOR_TODAYHide for today enabled
accountUsageLimitExceededERROR_CODE_ACCOUNT_USAGE_LIMIT_EXCEEDEDAccount usage limit exceeded
adLandscapeUnsupportedERROR_CODE_LANDSCAPE_UNSUPPORTEDLandscape mode not supported
backfillNoFillERROR_CODE_AD_BACKFILL_NO_FILLNo backfill ads available
undefinedUNDEFINEDUndefined error

Properties

PropertyTypeDescription
codeStringError code string

Factory Methods

MethodDescription
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

PropertyTypeDescription
creativeSizeCreativeSize?Creative size
adSizeSize?Banner view size setting

Methods

MethodReturn TypeDescription
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

CallbackParametersDescription
onAdReceivedunitId, metadataAd received successfully
onAdClickedunitId, metadataAd clicked
onAdImpressionunitId, metadataAd impression
onAdFailedToReceiveunitId, errorCodeAd failed to receive

Metadata Fields

FieldTypeDescription
creativeIdStringCreative ID
txIdStringTransaction ID
campaignIdStringCampaign ID
destinationURLStringDestination URL
browserTargetint?Browser target (0: external, 1: internal)

AdropNativeAd

Class for requesting native ads.

Constructor

AdropNativeAd({
  required String unitId,
  bool useCustomClick = false,
  AdropNativeListener? listener,
})

Properties

PropertyTypeDescription
isLoadedboolWhether ad is loaded
unitIdStringAd unit ID
creativeIdStringCreative ID
txIdStringTransaction ID
campaignIdStringCampaign ID
destinationURLStringDestination URL
browserTargetBrowserTarget?How the destination URL opens (external/internal browser)
propertiesAdropNativePropertiesNative ad properties
creativeSizeCreativeSizeCreative size
isBackfilledboolWhether it is a backfilled ad

Methods

MethodReturn TypeDescription
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

CallbackParametersDescription
onAdReceivedadAd received successfully
onAdClickedadAd clicked
onAdImpressionadAd impression
onAdFailedToReceivead, errorCodeAd failed to receive

AdropNativeProperties

Content properties for native ads.

Properties

PropertyTypeDescription
headlineString?Ad headline
bodyString?Ad body
creativeString?HTML creative content
assetString?Image asset URL
destinationURLString?URL to navigate on click
callToActionString?CTA button text
profileAdropNativeProfile?Advertiser profile info
extraMap<String, String>Additional custom fields
isBackfilledboolWhether it is a backfilled ad

AdropNativeProfile

Profile information for native ads.

Properties

PropertyTypeDescription
displayNameString?Advertiser name
displayLogoString?Advertiser logo image URL

AdropInterstitialAd

Class for displaying interstitial ads.

Constructor

AdropInterstitialAd({
  required String unitId,
  AdropInterstitialListener? listener,
})

Properties

PropertyTypeDescription
isLoadedboolWhether ad is loaded
unitIdStringAd unit ID
creativeIdStringCreative ID
txIdStringTransaction ID
campaignIdStringCampaign ID
destinationURLStringDestination URL
browserTargetBrowserTarget?How the destination URL opens (external/internal browser)

Methods

MethodReturn TypeDescription
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

CallbackDescription
onAdReceivedAd received successfully
onAdClickedAd clicked
onAdImpressionAd impression
onAdWillPresentFullScreenAd will present (iOS only)
onAdDidPresentFullScreenAd presented
onAdWillDismissFullScreenAd will dismiss (iOS only)
onAdDidDismissFullScreenAd dismissed
onAdFailedToReceiveAd failed to receive
onAdFailedToShowFullScreenAd failed to show
onAdBackButtonPressedBack button pressed while ad is displayed (Android only)

AdropRewardedAd

Class for displaying rewarded ads.

Constructor

AdropRewardedAd({
  required String unitId,
  AdropRewardedListener? listener,
})

Properties

PropertyTypeDescription
isLoadedboolWhether ad is loaded
unitIdStringAd unit ID
creativeIdStringCreative ID
txIdStringTransaction ID
campaignIdStringCampaign ID
destinationURLStringDestination URL
browserTargetBrowserTarget?How the destination URL opens (external/internal browser)
serverSideVerificationOptionsServerSideVerificationOptions?Server-side verification options (userId, customData)

Methods

MethodReturn TypeDescription
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

PropertyTypeDescription
userIdString?User identifier for server-side verification
customDataString?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

CallbackDescription
onAdReceivedAd received successfully
onAdClickedAd clicked
onAdImpressionAd impression
onAdWillPresentFullScreenAd will present (iOS only)
onAdDidPresentFullScreenAd presented
onAdWillDismissFullScreenAd will dismiss (iOS only)
onAdDidDismissFullScreenAd dismissed
onAdFailedToReceiveAd failed to receive
onAdFailedToShowFullScreenAd failed to show
onAdEarnRewardHandlerReward earned

AdropPopupAd

Class for displaying popup ads.

Constructor

AdropPopupAd({
  required String unitId,
  AdropPopupListener? listener,
  Color? closeTextColor,
  Color? hideForTodayTextColor,
  Color? backgroundColor,
})

Properties

PropertyTypeDescription
isLoadedboolWhether ad is loaded
unitIdStringAd unit ID
creativeIdStringCreative ID
txIdStringTransaction ID
campaignIdStringCampaign ID
destinationURLStringDestination URL
browserTargetBrowserTarget?How the destination URL opens (external/internal browser)
closeTextColorColor?Close button text color
hideForTodayTextColorColor?”Hide for today” text color
backgroundColorColor?Button background color

Methods

MethodReturn TypeDescription
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();

AdropPopupListener

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

MethodReturn TypeDescription
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

MethodReturn TypeDescription
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

PropertyTypeDescription
statusAdropConsentStatusCurrent consent status
canRequestAdsboolWhether ads can be requested
canShowPersonalizedAdsboolWhether personalized ads can be shown
errorString?Error message (null if no error)

AdropConsentStatus

Enum representing the user’s consent status.

Values

ValueDescription
unknownConsent status not yet determined
requiredConsent required (popup will be shown)
notRequiredConsent not required (non-GDPR region)
obtainedConsent already obtained

AdropConsentDebugGeography

Enum for testing consent flows with different geographies.

Values

ValueDescription
disabledUse actual device location
eeaTest GDPR (European Economic Area)
regulatedUSStateTest CCPA (California, etc.)
otherTest non-regulated regions

BrowserTarget

Enum controlling how destination URLs open when an ad is clicked.

Values

ValueDescription
externalOpens in the system’s default browser
internalOpens 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

PropertyTypeDescription
widthdoubleWidth
heightdoubleHeight

AdropProperties

Enum for predefined user property keys used with AdropMetrics.setProperty.

Values

ValueCodeDescription
ageAGEUser age
birthBIRTHUser birth date (yyyy, yyyyMM, yyyyMMdd format)
genderGDRUser 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

ValueCodeDescription
maleMMale
femaleFFemale
otherOOther
unknownUUnknown

Deprecated Classes

The following classes are deprecated and will be removed in a future version.
Deprecated ClassMigrationNotes
AdropBannerUse AdropBannerViewBanner ad widget. Replaced by AdropBannerView and AdropBannerListener
AdropNavigatorObserverCan be removedNo 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.
FormatTest Unit ID
Banner (320x50)PUBLIC_TEST_UNIT_ID_320_50
Banner (320x100)PUBLIC_TEST_UNIT_ID_320_100
NativePUBLIC_TEST_UNIT_ID_NATIVE
InterstitialPUBLIC_TEST_UNIT_ID_INTERSTITIAL
RewardedPUBLIC_TEST_UNIT_ID_REWARDED
Popup (Bottom)PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM
Popup (Center)PUBLIC_TEST_UNIT_ID_POPUP_CENTER
SplashPUBLIC_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