yodo1mas 0.0.5
yodo1mas: ^0.0.5 copied to clipboard
This Plugins enables to integrate Yodo1 MAS (Managed Ad Service) into your Flutter Project.
example/lib/main.dart
import 'dart:developer';
import 'dart:io';
import 'dart:math';
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:developer';
import 'package:flutter/services.dart';
import 'package:yodo1mas/testmasfluttersdktwo.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> {
String _platformVersion = 'Unknown';
@override
void initState() {
super.initState();
Yodo1MAS.instance.init("MRGhsxAuLgJ", false,(successful) {
});
//givereward();
Yodo1MAS.instance.setRewardListener((event, message) {
switch(event) {
case Yodo1MAS.AD_EVENT_OPENED:
print('RewardVideo AD_EVENT_OPENED');
break;
case Yodo1MAS.AD_EVENT_ERROR:
print('RewardVideo AD_EVENT_ERROR' + message);
break;
case Yodo1MAS.AD_EVENT_CLOSED:
print('RewardVideo finally? AD_EVENT_CLOSED');
givereward();
break;
case Yodo1MAS.AD_EVENT_EARNED:
print("====================================");
print('RewardVideo AD_EVENT_EARNED');
break;
}});
//Yodo1MAS.instance.showBannerAd();
initPlatformState();
//Yodo1MAS.instance.showBannerAd();
}
void givereward()
{
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
//Yodo1MAS.instance.showBannerAd();
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Unity Ads Example'),
),
body: const SafeArea(
child: YodoAdsExample(),
),
),
);
}
}
class YodoAdsExample extends StatefulWidget {
const YodoAdsExample({Key? key}) : super(key: key);
@override
_YodoAdsExampleState createState() => _YodoAdsExampleState();
}
class _YodoAdsExampleState extends State<YodoAdsExample> {
static bool _showBanner = false;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (_showBanner)
Yodo1MASBannerAd(
size: BannerSize.AdaptiveBanner,
onLoad: () => print('Banner loaded:'),
onOpen: () => print('Banner clicked:'),
onClosed: () => print('Banner clicked:'),
onLoadFailed: (message) =>
print('Banner Ad $message'),
onOpenFailed: (message) =>
print('Banner Ad $message'),
),
],
),
ElevatedButton(
onPressed: () {
//Yodo1MAS.instance.showInterstitialAd();
setState(() {
//_showBanner = !_showBanner;
Yodo1MAS.instance.showRewardAd();
});
},
child: Text(_showBanner ? 'Hide Banner' : 'Show Banner'),
),
],
),
);
}
static showinterstitial()
{
Yodo1MAS.instance.showInterstitialAd();
}
}