forked from ibhavikmakwana/FlutterPlayground
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmob_example.dart
More file actions
139 lines (139 loc) · 4.38 KB
/
admob_example.dart
File metadata and controls
139 lines (139 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//import 'package:firebase_admob/firebase_admob.dart';
//import 'package:flutter/material.dart';
//
//class AdMobExample extends StatefulWidget {
// final String title;
//
// AdMobExample(this.title);
//
// @override
// _AdMobExampleState createState() => _AdMobExampleState();
//}
//
//class _AdMobExampleState extends State<AdMobExample> {
// static const MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
// keywords: <String>['Flutter'],
// contentUrl: 'http://flutter.dev',
// childDirected: true,
// nonPersonalizedAds: true,
// );
//
// BannerAd _bannerAd;
// InterstitialAd _interstitialAd;
// int _coins = 0;
//
// BannerAd createBannerAd() {
// return BannerAd(
// adUnitId: BannerAd.testAdUnitId, //Replace test unit ID wth actual Unit ID
// size: AdSize.banner,
// targetingInfo: targetingInfo,
// listener: (MobileAdEvent event) {
// print("BannerAd event $event");
// },
// );
// }
//
// InterstitialAd createInterstitialAd() {
// return InterstitialAd(
// adUnitId: InterstitialAd.testAdUnitId,
// //Replace test unit ID wth actual Unit ID
// targetingInfo: targetingInfo,
// listener: (MobileAdEvent event) {
// print("InterstitialAd event $event");
// },
// );
// }
//
// @override
// void initState() {
// super.initState();
// FirebaseAdMob.instance.initialize(
// appId: FirebaseAdMob.testAppId); //Replace test app ID wth actual app ID
// _bannerAd = createBannerAd()..load();
// RewardedVideoAd.instance.listener =
// (RewardedVideoAdEvent event, {String rewardType, int rewardAmount}) {
// print("RewardedVideoAd event $event");
// if (event == RewardedVideoAdEvent.rewarded) {
// setState(() {
// _coins += rewardAmount;
// });
// }
// };
// }
//
// @override
// void dispose() {
// _bannerAd?.dispose();
// _interstitialAd?.dispose();
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// return MaterialApp(
// home: Scaffold(
// appBar: AppBar(
// title: Text(widget.title),
// ),
// body: SingleChildScrollView(
// child: Center(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// RaisedButton(
// child: const Text('SHOW BANNER'),
// onPressed: () {
// _bannerAd ??= createBannerAd();
// _bannerAd
// ..load()
// ..show();
// }),
// RaisedButton(
// child: const Text('REMOVE BANNER'),
// onPressed: () {
// _bannerAd?.dispose();
// _bannerAd = null;
// }),
// RaisedButton(
// child: const Text('LOAD INTERSTITIAL'),
// onPressed: () {
// _interstitialAd?.dispose();
// _interstitialAd = createInterstitialAd()..load();
// },
// ),
// RaisedButton(
// child: const Text('SHOW INTERSTITIAL'),
// onPressed: () {
// _interstitialAd?.show();
// },
// ),
// RaisedButton(
// child: const Text('LOAD REWARDED VIDEO'),
// onPressed: () {
// RewardedVideoAd.instance.load(
// adUnitId: RewardedVideoAd.testAdUnitId,
// //Replace test unit ID wth actual Unit ID
// targetingInfo: targetingInfo);
// },
// ),
// RaisedButton(
// child: const Text('SHOW REWARDED VIDEO'),
// onPressed: () {
// RewardedVideoAd.instance.show();
// },
// ),
// Text("You have $_coins coins."),
// ].map((Widget button) {
// return Padding(
// padding: const EdgeInsets.symmetric(vertical: 16.0),
// child: button,
// );
// }).toList(),
// ),
// ),
// ),
// ),
// );
// }
//}