bluestack_sdk_flutter 2.1.0 copy "bluestack_sdk_flutter: ^2.1.0" to clipboard
bluestack_sdk_flutter: ^2.1.0 copied to clipboard

BlueStack Flutter plugin for interstitial, rewarded, and banner ad integration on Android and iOS apps.

BlueStack SDK Flutter Plugin #

A Flutter plugin for integrating BlueStack SDK in your Flutter applications. This plugin provides a comprehensive set of tools for displaying various types of ads including interstitial, rewarded, and banner ads.

Features #

  • SDK Initialization - Simple one-time initialization with debug mode support
  • Interstitial Ads - Full-screen ads with comprehensive event handling
  • Rewarded Ads - Video ads with reward callback support
  • Banner Ads - Multiple banner sizes with automatic refresh support
  • Event Handling - Comprehensive callback system for ad lifecycle events
  • Platform Support - Full support for both Android and iOS

Requirements #

  • Flutter SDK: Flutter 3.3.0 or higher
  • Android: minSdkVersion 23, target/compileSdkVersion 35, Kotlin 2.0+
  • iOS: platform 13.0+, Xcode 15 with CocoaPods 1.14+

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  bluestack_sdk_flutter: ^2.1.0

Usage #

Initialize the SDK #

import 'package:bluestack_sdk_flutter/bluestack_sdk_flutter.dart';

// Set up initialization event listeners
BlueStackInitializer.setEventListener(InitializationEventListener(
  onInitializationSuccess: (adapterStatus) {
    print('SDK initialized successfully');
  },
  onInitializationFail: (error) {
    print('SDK initialization failed: ${error.toString()}');
  },
));

// Initialize the SDK
BlueStackInitializer.initialize(
  appId: "YOUR_APP_ID",
  enableDebug: true, // Set to false for production
);

Interstitial Ads #

// Create an interstitial ad instance
final interstitialAd = InterstitialAd('/YOUR_APP_ID/interstitial');

// Set up load event listeners
interstitialAd.setLoadEventListener(InterstitialAdLoadEventListener(
  onAdLoaded: () {
    print('Interstitial ad loaded');
  },
  onAdFailedToLoad: (error) {
    print('Interstitial ad failed to load: ${error.message}');
  },
));

// Set up show event listeners
interstitialAd.setShowEventListener(InterstitialAdShowEventListener(
  onAdDisplayed: () {
    print('Interstitial ad displayed');
  },
  onAdFailedToDisplay: (error) {
    print('Interstitial ad failed to display: ${error.message}');
  },
  onAdDismissed: () {
    print('Interstitial ad dismissed');
  },
  onAdClicked: () {
    print('Interstitial ad clicked');
  },
));

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

// Show the ad
await interstitialAd.show();

// Don't forget to dispose when done
interstitialAd.dispose();

Rewarded Ads #

// Create a rewarded ad instance
final rewardedAd = RewardedAd('/YOUR_APP_ID/rewardedVideo');

// Set up load event listeners
rewardedAd.setLoadEventListener(RewardedAdLoadEventListener(
  onAdLoaded: () {
    print('Rewarded ad loaded');
  },
  onAdFailedToLoad: (error) {
    print('Rewarded ad failed to load: ${error.message}');
  },
));

// Set up show event listeners
rewardedAd.setShowEventListener(RewardedAdShowEventListener(
  onAdDisplayed: () {
    print('Rewarded ad displayed');
  },
  onAdFailedToDisplay: (error) {
    print('Rewarded ad failed to display: ${error.message}');
  },
  onAdDismissed: () {
    print('Rewarded ad dismissed');
  },
  onAdClicked: () {
    print('Rewarded ad clicked');
  },
  onRewarded: (reward) {
    print('Rewarded: ${reward.type} - ${reward.amount}');
  },
));

// Load the ad
await rewardedAd.load();

// Show the ad
await rewardedAd.show();

// Don't forget to dispose when done
rewardedAd.dispose();
// Create a banner view
BannerView(
  type: BannerAdSize.banner, // Choose from various sizes
  placementId: '/YOUR_APP_ID/banner',
  shouldLoadWhenReady: false,
  options: options,
  onAdLoaded: (size) {
    print('Banner ad loaded with size: $size');
  },
  onAdFailedToLoad: (error) {
    print('Banner ad failed to load: ${error.message}');
  },
  onAdClicked: () {
    print('Banner ad clicked');
  },
  onAdRefreshed: () {
    print('Banner ad refreshed');
  },
  onAdFailedToRefresh: (error) {
    print('Banner ad failed to refresh: ${error.message}');
  },
)

// Control banner visibility
bannerViewKey.currentState?.toggleVisibility(true);

// Control banner refresh
bannerViewKey.currentState?.toggleRefresh(true);

// Destroy banner when done
bannerViewKey.currentState?.destroy();

Available Banner Sizes #

enum BannerAdSize {
  banner,          // 320x50
  largeBanner,     // 320x100
  fullBanner,      // 468x60
  mediumRectangle, // 300x250
  leaderboard,     // 728x90
  dynamicBanner,   // width varies, height 50
  dynamicLeaderboard // width varies, height 90
}

Request Options #

You can customize ad requests using RequestOptions:

final RequestOptions options = RequestOptions();

  options.setAge(25)
  options.setLanguage('en')
  options.setGender(Gender.female)
  options.setKeyword('testbrand=myBrand;category=sport');
  /// [location] The geographical location of the user.
  /// [consentFlag] The consent status for using location data.
  options.setLocation(
    Location(
        latitude: 37.7749,
        longitude: -122.4194,
        provider: LocationProvider.gps),
    1);
  options.setContentUrl('https://developers.bluestack.app/');

  rewardedAd.load(options: options);

Example #

Check the example directory for a complete example app demonstrating all features.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

0
likes
150
points
38
downloads
screenshot

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

BlueStack Flutter plugin for interstitial, rewarded, and banner ad integration on Android and iOS apps.

Homepage

Topics

#bluestack #ads #interstitial #rewarded #banner

License

Apache-2.0 (license)

Dependencies

flutter, meta

More

Packages that depend on bluestack_sdk_flutter

Packages that implement bluestack_sdk_flutter