stack_appodeal_flutter 1.2.0 stack_appodeal_flutter: ^1.2.0 copied to clipboard
Flutter plugin to support Appodeal SDK for Android and iOS platforms. Support Consent Dialog for GDPR/CCPA zone.
import 'dart:async';
import 'package:appodeal_flutter_example/Interstitial.dart';
import 'package:appodeal_flutter_example/banner.dart';
import 'package:appodeal_flutter_example/banner_view.dart';
import 'package:appodeal_flutter_example/consent_manager.dart';
import 'package:appodeal_flutter_example/mrec_view.dart';
import 'package:appodeal_flutter_example/rewarded_video.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:stack_appodeal_flutter/stack_appodeal_flutter.dart';
import 'ext.dart';
void main() {
runApp(MaterialApp(
home: AppodealDemoApp(),
));
}
class AppodealDemoApp extends StatefulWidget {
@override
_AppodealDemoAppState createState() => _AppodealDemoAppState();
}
class _AppodealDemoAppState extends State<AppodealDemoApp> {
@override
void initState() {
super.initState();
}
Future<void> initialization() async {
Appodeal.setTesting(kReleaseMode ? false : true); //only not release mode
Appodeal.setLogLevel(Appodeal.LogLevelVerbose);
Appodeal.setAutoCache(Appodeal.INTERSTITIAL, false);
Appodeal.setAutoCache(Appodeal.REWARDED_VIDEO, false);
Appodeal.setUseSafeArea(true);
Appodeal.initialize(
appodealKey,
[
Appodeal.REWARDED_VIDEO,
Appodeal.INTERSTITIAL,
Appodeal.BANNER,
Appodeal.MREC
],
boolConsent: false,
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('Appodeal Flutter Demo'),
),
body: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(
left: 4.0, right: 4.0, top: 8.0, bottom: 4.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20),
fixedSize: Size(300, 20)),
onPressed: () {
initialization();
},
child: const Text('INITIALIZATION'),
),
),
],
),
//Header
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(
left: 4.0, right: 4.0, top: 8.0, bottom: 4.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20),
fixedSize: Size(300, 20)),
onPressed: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => InterstitialPage()),
);
},
child: const Text('INTERSTITIAL'),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(4.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20),
fixedSize: Size(300, 20)),
onPressed: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RewardedVideoPage()),
);
},
child: const Text('REWARDED VIDEO'),
),
),
],
),
//Interstitial
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(4.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20),
fixedSize: Size(300, 20)),
onPressed: () async {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => BannerPage()),
);
},
child: const Text('BANNER'),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(4.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20),
fixedSize: Size(300, 20)),
onPressed: () async {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => BannerViewPage()),
);
},
child: const Text('BANNER VIEW'),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(4.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20),
fixedSize: Size(300, 20)),
onPressed: () async {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => MrecViewPage()),
);
},
child: const Text('MREC VIEW'),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(4.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20),
fixedSize: Size(300, 20)),
onPressed: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ConsentManagerPage()),
);
},
child: const Text('CONSENT MANAGER'),
),
),
],
),
]),
),
);
}
}
void showToast(String message) => print(message);