flutter_mintegral 1.5.2 flutter_mintegral: ^1.5.2 copied to clipboard
Mintegral SDK for Android
Flutter Mintegral Plugin #
The flutter_mintegral
plugin provides integration with the Mintegral SDK for displaying ads in your Flutter applications. This is currently only compatible with Android.
Features #
- Display various types of ads, including banner ads, interstitial ads, rewarded video ads, and splash ads.
- Handle ad events, such as ad loading, ad impression, ad click, ad dismissal, and more.
- Support for callbacks and listeners to track and respond to ad events.
- Initialize the Mintegral SDK with your app ID and app key.
- Comprehensive error handling for ad loading and initialization failures.
Installation #
To use the flutter_mintegral
plugin, follow these steps:
- Add the following dependency to your
pubspec.yaml
file:
dependencies:
flutter_mintegral: ^x.x.x
Replace ^x.x.x
with the latest version of the plugin.
- Run the following command to install the dependencies:
flutter pub get
- Import the
flutter_mintegral
package in your Dart code:
import 'package:flutter_mintegral/flutter_mintegral.dart';
- Initialize the Mintegral SDK with your app ID and app key using the
initialize
method:
await Mintegral.instance.initialize(
appId: 'your_app_id',
appKey: 'your_app_key',
onInitSuccess: () {
// Mintegral SDK initialization successful
},
onInitFail: (error) {
// Mintegral SDK initialization failed
},
);
Usage #
Displaying Banner Ads #
To display banner ads, you can use the BannerAd
class. Here's an example:
BannerAd bannerAd = BannerAd(
adUnitId: 'your_banner_ad_unit_id',
adSize: AdSize.banner,
listener: BannerAdListener(
onAdLoaded: (ad) {
// Banner ad loaded successfully
},
onAdFailedToLoad: (ad, error) {
// Banner ad failed to load
},
// Other ad event callbacks
),
);
// Load and show the banner ad
bannerAd.load();
bannerAd.show();
Displaying Interstitial Ads #
To display interstitial ads, you can use the InterstitialAd
class. Here's an example:
InterstitialAd interstitialAd = InterstitialAd(
adUnitId: 'your_interstitial_ad_unit_id',
listener: InterstitialAdLoadCallback(
onAdLoaded: (ad) {
// Interstitial ad loaded successfully
},
onAdFailedToLoad: (ad, error) {
// Interstitial ad failed to load
},
// Other ad event callbacks
),
);
// Load and show the interstitial ad
interstitialAd.load();
interstitialAd.show();
Displaying Rewarded Video Ads #
To display rewarded video ads, you can use the RewardVideoAd
class. Here's an example:
RewardVideoAd rewardedAd = RewardVideoAd(
adUnitId: 'your_rewarded_ad_unit_id',
listener: RewardedAdLoadCallback(
onAdLoaded: (ad) {
// Rewarded video ad loaded successfully
},
onAdFailedToLoad: (ad, error) {
// Rewarded video ad failed to load
},
// Other ad event callbacks
),
);
// Load and show the rewarded video ad
rewardedAd.load();
rewardedAd.show();
Displaying Splash Ads #
To display splash ads, you can use the SplashAd
class. Here's an example:
SplashAd splashAd = SplashAd(
adUnitId: 'your_splash_ad_unit_id',
adContainer: YourAdContainerWidget(),
callback: SplashContentCallback<Ad>(
onAdShowedFullScreenContent: (ad) {
// Splash ad showed full screen content
},
onAdDismissedFullScreenContent: (ad, dismissType) {
// Splash ad dismissed full screen content
},
// Other ad event callbacks
),
);
// Load and show the splash ad
splashAd.load();
splashAd.show();
Make sure to replace 'your_app_id'
, 'your_app_key'
, 'your_banner_ad_unit_id'
, 'your_interstitial_ad_unit_id'
, 'your_rewarded_ad_unit_id'
, and 'your_splash_ad_unit_id'
with the appropriate values for your application. Additionally, update the link to the actual repository for the flutter_mintegral
plugin.