Skip to main content

Adrop

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

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

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);

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
creativeSizeWidthdoubleCreative width
creativeSizeHeightdoubleCreative height

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
propertiesAdropNativePropertiesNative ad properties
creativeSizeCreativeSizeCreative size
isBackfilledboolWhether 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 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

Methods

MethodReturn TypeDescription
load()Future<void>Load ad
show()Future<void>Show ad
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,
})

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

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

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

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
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
logEvent(String name, [dynamic params])Future<void>Log event
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);

// Log event
await AdropMetrics.logEvent('purchase', {
  'item_id': 'SKU_001',
  'price': 29900,
});

// Get all properties
final props = await AdropMetrics.properties();
debugPrint('Properties: $props');

CreativeSize

Class representing the size of a creative.

Constructor

const CreativeSize({
  required double width,
  required double height,
})

Properties

PropertyTypeDescription
widthdoubleWidth
heightdoubleHeight

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.