-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathadmob.dart
111 lines (96 loc) · 2.4 KB
/
admob.dart
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
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:firebase_admob/firebase_admob.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: MyApp2(),
);
}
}
class MyApp2 extends StatefulWidget {
@override
_MyApp2State createState() => _MyApp2State();
}
class _MyApp2State extends State<MyApp2> {
static final MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
keywords: <String>[
'travel',
'backpackers',
'hotel',
'lifestyle',
],
contentUrl: 'https://www.caspian.my',
childDirected: true,
testDevices: <String>[],
);
BannerAd myBanner = BannerAd(
//adUnitId: BannerAd.testAdUnitId,
adUnitId: "ca-app-pub-4895721634232616/7556063456",
size: AdSize.smartBanner,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("BannerAd event:- $event");
},
);
// InterstitialAd myInterstitial = InterstitialAd(
// adUnitId: InterstitialAd.testAdUnitId,
// //adUnitId: "ca-app-pub-2650672046813337/3594268143",
// targetingInfo: targetingInfo,
// listener: (MobileAdEvent event) {
// print("InterstitialAd event:- $event");
// },
// );
@override
void initState() {
FirebaseAdMob.instance
.initialize(appId: "ca-app-pub-xxxxxxxxxxxxx~xxxxxxxxx");
myBanner
..load()
..show();
super.initState();
}
@override
void dispose() {
myBanner.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final welcometext = Padding(
padding: EdgeInsets.fromLTRB(10, 120, 10, 0),
child: Text(
'Welcome',
style: TextStyle(fontSize: 30),
),
);
// final totext = Padding(
// padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
// child: Text(
// 'to',
// style: TextStyle(fontSize: 20),
// ),
// );
final mybody = Container(
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.all(28.0),
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
Colors.blue,
Colors.cyan[100],
]),
),
child: Column(
children: <Widget>[
welcometext,
],
),
);
return Scaffold(
body: mybody,
);
}
}