Adrop
The main class for the Adrop SDK. Handles SDK initialization and global settings.
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 |
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
| 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 |
creativeSizeWidth | double | Creative width |
creativeSizeHeight | double | Creative height |
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 |
properties | AdropNativeProperties | Native ad properties |
creativeSize | CreativeSize | Creative size |
isBackfilled | bool | Whether 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 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 |
Methods
| Method | Return Type | Description |
|---|
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
| 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 |
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 |
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();
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 |
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 |
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
| Property | Type | Description |
|---|
width | double | Width |
height | double | Height |
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.