cs_ironsource_ad 0.0.3 cs_ironsource_ad: ^0.0.3 copied to clipboard
Ironsource adware
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().initSDK(appKey: "appKey");
CsIronsourceAd().setUserId(userId: "userId");
}
void offerwallAvailable(bool isAvailable) {
log("广告 offerwallAvailable:" + isAvailable.toString());
}
void offerwallOpened() {
log("广告 offerwallAvailable");
}
void offerwallShowFailed(int code) {
log("广告 offerwallShowFailed:" + code.toString());
}
void offerwallAdCredited(int credits, int totalCredits, bool totalCreditsFlag) {
log("广告 offerwallAdCredited:" + credits.toString() + ", totalCredits:" + totalCredits.toString() + ", totalCreditsFlag:" + totalCreditsFlag.toString());
}
void getOfferwallCreditsFailed(int code) {
log("广告 getOfferwallCreditsFailed:" + code.toString());
}
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) {
log("广告 ironsource RewardedVideoAdShowFailed:" + code.toString());
}
void rewardedVideoAdClicked(String rewardName, int rewardAmount) {
log("广告 ironsource RewardedVideoAdClicked:" + rewardName + ", rewardAmount:" + rewardAmount.toString());
}
void interstitialAdReady() {
log("广告 InterstitialAdReady");
}
void interstitialAdLoadFailed(int code) {
log("广告 InterstitialAdLoadFailed:" + code.toString());
}
void interstitialAdOpened() {
log("广告 InterstitialAdOpened");
}
void interstitialAdClosed() {
log("广告 InterstitialAdClosed");
}
void interstitialAdShowSucceeded() {
log("广告 InterstitialAdShowSucceeded");
}
void interstitialAdShowFailed(int code) {
log("广告 InterstitialAdShowFailed:" + code.toString());
}
void interstitialAdClicked() {
log("广告 InterstitialAdClicked");
}
@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))),
),
),
);
}
}