Getting Started
This section provides a comprehensive guide on integrating the BlueStack Flutter Plugin into your project. Our plugin offers a range of functionalities to monetize your mobile application, including premium sales with rich media, video, and innovative formats, as well as support for all standard display formats. This plugin is compatible with both iOS and Android applications.
Prerequisites
-
Use Flutter 3.3.0 or higher
-
Android
- Minimum SDK version of 23 or higher
- Compile SDK version of 31 or higher
-
iOS
- Use Xcode 16.0 or higher
- iOS 13 or higher
Plugin Integration
Installation
Add the plugin to your pubspec.yaml:
dependencies:
bluestack_sdk_flutter: ^2.0.0
Import sdk component
import 'package:bluestack_sdk_flutter/bluestack_sdk.dart';
SDK Implementation
Initialize the SDK in your application
You need to initialize SDK using the App Id (depends on the platform), before you request any kind of ads. You need to call initialize method of BlueStackInitializer with your appId to initialize the SDK. You can also set the 2nd parameter (optional) enableDebug to true, if you want to enable debug option.
By default enableDebug is false.
You have to register your app in BlueStack console to get an App Id for your app.
Here's an example of how to initialize the SDK:
void main() {
// Initialize the SDK
BlueStackInitializer.initialize(
appId: "YOUR_APP_ID",
enableDebug: true, // Set to false for production
);
runApp(MyApp());
}
Register listeners for SDK initialization callbacks
You must set the listener callbacks before calling the initialize method; otherwise, you may not receive them.
BlueStackInitializer exposes the following events through its lifecycle.
| Events | Definition |
|---|---|
| onInitializationSuccess | The SDK has been successfully initialized with adapterStatus |
| onInitializationFail | The SDK failed to initialize with error |
Here's an example of how to register event listeners for SDK initialization:
BlueStackInitializer.setEventListener(InitializationEventListener(
onInitializationSuccess: (adapterStatus) {
print('BlueStack SDK has been successfully initialized');
},
onInitializationFail: (error) {
print('BlueStack SDK failed to initialize: ${error.toString()}');
},
));