yodo1mas 0.0.3
yodo1mas: ^0.0.3 copied to clipboard
This Plugins enables to integrate Yodo1 MAS (Managed Ad Service) into your Flutter Project.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:testmasfluttersdktwo/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) {
});
//Yodo1MAS.instance.showBannerAd();
initPlatformState();
//Yodo1MAS.instance.showBannerAd();
}
// 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> {
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.Banner,
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: () {
setState(() {
_showBanner = !_showBanner;
});
},
child: Text(_showBanner ? 'Hide Banner' : 'Show Banner'),
),
],
),
);
}
}