adalam_flutter 0.1.1 copy "adalam_flutter: ^0.1.1" to clipboard
adalam_flutter: ^0.1.1 copied to clipboard

PlatformAndroid

AdAlam Ad SDK for Flutter — Banner, Interstitial, and Rewarded ads for Android.

AdAlam Flutter SDK #

A Flutter plugin for the AdAlam ad network, providing easy integration for Banner, Interstitial, and Rewarded ads on Android.

Installation #

Add the dependency to your pubspec.yaml referencing the repository and path:

dependencies:
  adalam_flutter:
    git:
      url: https://github.com/AdalamAds/adalam-plugin-repo.git
      path: sdks/flutter/adalam_flutter

Option 2: Local Path (For Development) #

If you have the source locally:

dependencies:
  adalam_flutter:
    path: ../path/to/adalam_flutter

Setup #

Android #

Ensure your app has Internet permissions in android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>

Usage #

1. Initialization #

Initialize the SDK early in your app lifecycle.

import 'package:adalam_flutter/adalam_flutter.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  try {
    // Optionally enable Test Mode during development
    await AdAlam.setTestMode(true);
    
    await AdAlam.initialize(
      appId: 'your_app_id_here',
      apiKey: 'your_api_key_here',
    );
  } on AdAlamException catch (e) {
    debugPrint('Init failed: $e');
  }
  
  runApp(MyApp());
}

2. Banner Ads #

Use the BannerAdWidget inline in your widget tree.

BannerAdWidget(
  placementKey: 'home_banner',
  size: BannerSize.standard, // standard (320x50), mediumRect (300x250), large (320x90)
  listener: AdListener(
    onLoaded: () => print('Banner loaded'),
    onFailed: (error) => print('Banner failed: $error'),
    onClicked: () => print('Banner clicked'),
  ),
)

3. Interstitial Ads #

Load an interstitial ad before showing it.

final interstitialAd = InterstitialAd(placementKey: 'level_complete');

// 1. Setup listener
interstitialAd.listener = AdListener(
  onLoaded: () => print('Ad loaded'),
  onFailed: (e) => print('Ad failed: $e'),
  onClosed: () {
    print('Ad closed');
    // Load the next ad
    interstitialAd.load();
  },
);

// 2. Load the ad
await interstitialAd.load();

// 3. Show later
if (interstitialAd.isLoaded) {
  await interstitialAd.show();
}

4. Rewarded Ads #

Rewarded ads work identically to Interstitial ads, but provide an onReward callback.

final rewardedAd = RewardedAd(placementKey: 'watch_to_earn');

rewardedAd.listener = AdListener(
  onLoaded: () => print('Rewarded ad ready'),
  onReward: (reward) {
    print('User earned ${reward.amount} ${reward.type}');
    // Grant virtual currency
  },
  onClosed: () => rewardedAd.load(),
);

await rewardedAd.load();

// Later...
if (rewardedAd.isLoaded) {
  await rewardedAd.show();
}
0
likes
140
points
112
downloads

Publisher

unverified uploader

Weekly Downloads

AdAlam Ad SDK for Flutter — Banner, Interstitial, and Rewarded ads for Android.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on adalam_flutter

Packages that implement adalam_flutter