cs_ironsource_ad 0.0.6 cs_ironsource_ad: ^0.0.6 copied to clipboard
Ironsource adware SDK 7.2.0
example/lib/main.dart
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:cs_ironsource_ad/cs_ironsource_ad.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
CsIronsourceAd().setOfferwallAvailable(offerwallAvailable);
CsIronsourceAd().setOfferwallOpened(offerwallOpened);
CsIronsourceAd().setOfferwallShowFailed(offerwallShowFailed);
CsIronsourceAd().setOfferwallAdCredited(offerwallAdCredited);
CsIronsourceAd().setGetOfferwallCreditsFailed(getOfferwallCreditsFailed);
CsIronsourceAd().setOfferwallClosed(offerwallClosed);
CsIronsourceAd().setRewardedVideoAdOpened(rewardedVideoAdOpened);
CsIronsourceAd().setRewardedVideoAdClosed(rewardedVideoAdClosed);
CsIronsourceAd().setRewardedVideoAvailabilityChanged(rewardedVideoAvailabilityChanged);
CsIronsourceAd().setRewardedVideoAdStarted(rewardedVideoAdStarted);
CsIronsourceAd().setRewardedVideoAdEnded(rewardedVideoAdEnded);
CsIronsourceAd().setRewardedVideoAdRewarded(rewardedVideoAdRewarded);
CsIronsourceAd().setRewardedVideoAdShowFailed(rewardedVideoAdShowFailed);
CsIronsourceAd().setRewardedVideoAdClicked(rewardedVideoAdClicked);
CsIronsourceAd().setInterstitialAdReady(interstitialAdReady);
CsIronsourceAd().setInterstitialAdLoadFailed(interstitialAdLoadFailed);
CsIronsourceAd().setInterstitialAdOpened(interstitialAdOpened);
CsIronsourceAd().setInterstitialAdClosed(interstitialAdClosed);
CsIronsourceAd().setInterstitialAdShowSucceeded(interstitialAdShowSucceeded);
CsIronsourceAd().setInterstitialAdShowFailed(interstitialAdShowFailed);
CsIronsourceAd().setInterstitialAdClicked(interstitialAdClicked);
CsIronsourceAd().setOnIronSourceAdLog(onIronSourceAdLog);
CsIronsourceAd().initSDK(appKey: "xxxx");
CsIronsourceAd().setUserId(userId: "userId");
}
void offerwallAvailable(bool isAvailable) {
log("广告 offerwallAvailable:" + isAvailable.toString());
}
void offerwallOpened() {
log("广告 offerwallAvailable");
}
void offerwallShowFailed(int code, String message) {
log("广告 offerwallShowFailed:" + code.toString() + " - " + message);
}
void offerwallAdCredited(int credits, int totalCredits, bool totalCreditsFlag) {
log("广告 offerwallAdCredited:" + credits.toString() + ", totalCredits:" + totalCredits.toString() + ", totalCreditsFlag:" + totalCreditsFlag.toString());
}
void getOfferwallCreditsFailed(int code, String message) {
log("广告 getOfferwallCreditsFailed:" + code.toString() + " - " + message);
}
void offerwallClosed() {
log("广告 offerwallClosed");
}
void rewardedVideoAdOpened() {
log("广告 RewardedVideoAdOpened");
}
void rewardedVideoAdClosed() {
log("广告 RewardedVideoAdClosed");
}
void rewardedVideoAvailabilityChanged(bool isAvailable) {
log("广告 ironsource RewardedVideoAvailabilityChanged:" + isAvailable.toString());
}
void rewardedVideoAdStarted() {
log("广告 ironsource RewardedVideoAdStarted");
}
void rewardedVideoAdEnded() {
log("广告 ironsource RewardedVideoAdEnded");
}
void rewardedVideoAdRewarded(String rewardName, int rewardAmount) {
log("广告 ironsource RewardedVideoAdRewarded:" + rewardName + ", rewardAmount:" + rewardAmount.toString());
}
void rewardedVideoAdShowFailed(int code, String message) {
log("广告 ironsource RewardedVideoAdShowFailed:" + code.toString() + " - " + message);
}
void rewardedVideoAdClicked(String rewardName, int rewardAmount) {
log("广告 ironsource RewardedVideoAdClicked:" + rewardName + ", rewardAmount:" + rewardAmount.toString());
}
void interstitialAdReady() {
log("广告 InterstitialAdReady");
}
void interstitialAdLoadFailed(int code, String message) {
log("广告 InterstitialAdLoadFailed:" + code.toString() + " - " + message);
}
void interstitialAdOpened() {
log("广告 InterstitialAdOpened");
}
void interstitialAdClosed() {
log("广告 InterstitialAdClosed");
}
void interstitialAdShowSucceeded() {
log("广告 InterstitialAdShowSucceeded");
}
void interstitialAdShowFailed(int code, String message) {
log("广告 InterstitialAdShowFailed:" + code.toString() + " - " + message);
}
void interstitialAdClicked() {
log("广告 InterstitialAdClicked");
}
void onIronSourceAdLog(String? tag, String? p2, int p3) {
log("广告 onIronSourceAdLog:" + (tag ?? "") + ", p2:" + (p2 ?? "") + ", p3:" + p3.toString());
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: TextButton(
onPressed: () {
CsIronsourceAd().isOfferwallAvailable().then((available) {
if (available ?? false) {
CsIronsourceAd().showOfferwall("Startup");
} else {
log("广告 isOfferwallAvailable 失败");
}
}).onError((error, stackTrace) {
log("广告 isOfferwallAvailable:" + error.toString());
});
},
child: const Text('show adddd', style: TextStyle(color: Colors.red))),
),
),
);
}
}