Skip to content

Commit ccb243a

Browse files
committed
Update dart format of samples
1 parent f0525b5 commit ccb243a

File tree

9 files changed

+115
-139
lines changed

9 files changed

+115
-139
lines changed

samples/admob/app_open_example/lib/app_open_ad_manager.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ class AppOpenAdManager {
2929
AppOpenAd? _appOpenAd;
3030
bool _isShowingAd = false;
3131

32-
String adUnitId =
33-
Platform.isAndroid
34-
? 'ca-app-pub-3940256099942544/9257395921'
35-
: 'ca-app-pub-3940256099942544/5575463023';
32+
String adUnitId = Platform.isAndroid
33+
? 'ca-app-pub-3940256099942544/9257395921'
34+
: 'ca-app-pub-3940256099942544/5575463023';
3635

3736
/// Load an [AppOpenAd].
3837
void loadAd() async {

samples/admob/app_open_example/lib/main.dart

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,14 @@ class _HomePageState extends State<HomePage> {
108108

109109
return <Widget>[
110110
PopupMenuButton<AppBarItem>(
111-
itemBuilder:
112-
(context) =>
113-
array
114-
.map(
115-
(item) => PopupMenuItem<AppBarItem>(
116-
value: item,
117-
child: Text(item.label),
118-
),
119-
)
120-
.toList(),
111+
itemBuilder: (context) => array
112+
.map(
113+
(item) => PopupMenuItem<AppBarItem>(
114+
value: item,
115+
child: Text(item.label),
116+
),
117+
)
118+
.toList(),
121119
onSelected: (item) {
122120
switch (item.value) {
123121
case 0:

samples/admob/banner_example/lib/main.dart

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ class BannerExampleState extends State<BannerExample> {
2727
bool _isLoaded = false;
2828
Orientation? _currentOrientation;
2929

30-
final String _adUnitId =
31-
Platform.isAndroid
32-
? 'ca-app-pub-3940256099942544/9214589741'
33-
: 'ca-app-pub-3940256099942544/2435281174';
30+
final String _adUnitId = Platform.isAndroid
31+
? 'ca-app-pub-3940256099942544/9214589741'
32+
: 'ca-app-pub-3940256099942544/2435281174';
3433

3534
@override
3635
void initState() {
@@ -103,16 +102,14 @@ class BannerExampleState extends State<BannerExample> {
103102

104103
return <Widget>[
105104
PopupMenuButton<AppBarItem>(
106-
itemBuilder:
107-
(context) =>
108-
array
109-
.map(
110-
(item) => PopupMenuItem<AppBarItem>(
111-
value: item,
112-
child: Text(item.label),
113-
),
114-
)
115-
.toList(),
105+
itemBuilder: (context) => array
106+
.map(
107+
(item) => PopupMenuItem<AppBarItem>(
108+
value: item,
109+
child: Text(item.label),
110+
),
111+
)
112+
.toList(),
116113
onSelected: (item) {
117114
switch (item.value) {
118115
case 0:

samples/admob/interstitial_example/lib/main.dart

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ class InterstitialExampleState extends State<InterstitialExample> {
3131
late var _counter = _gameLength;
3232
Timer? _timer;
3333

34-
final String _adUnitId =
35-
Platform.isAndroid
36-
? 'ca-app-pub-3940256099942544/1033173712'
37-
: 'ca-app-pub-3940256099942544/4411468910';
34+
final String _adUnitId = Platform.isAndroid
35+
? 'ca-app-pub-3940256099942544/1033173712'
36+
: 'ca-app-pub-3940256099942544/4411468910';
3837

3938
@override
4039
void initState() {
@@ -141,16 +140,14 @@ class InterstitialExampleState extends State<InterstitialExample> {
141140

142141
return <Widget>[
143142
PopupMenuButton<AppBarItem>(
144-
itemBuilder:
145-
(context) =>
146-
array
147-
.map(
148-
(item) => PopupMenuItem<AppBarItem>(
149-
value: item,
150-
child: Text(item.label),
151-
),
152-
)
153-
.toList(),
143+
itemBuilder: (context) => array
144+
.map(
145+
(item) => PopupMenuItem<AppBarItem>(
146+
value: item,
147+
child: Text(item.label),
148+
),
149+
)
150+
.toList(),
154151
onSelected: (item) {
155152
_pauseGame();
156153
switch (item.value) {
@@ -219,20 +216,19 @@ class InterstitialExampleState extends State<InterstitialExample> {
219216
void _showAlert(BuildContext context) {
220217
showDialog(
221218
context: context,
222-
builder:
223-
(context) => AlertDialog(
224-
title: const Text('Game Over'),
225-
content: Text('You lasted $_gameLength seconds'),
226-
actions: <Widget>[
227-
TextButton(
228-
onPressed: () {
229-
Navigator.pop(context);
230-
_interstitialAd?.show();
231-
},
232-
child: const Text('OK'),
233-
),
234-
],
219+
builder: (context) => AlertDialog(
220+
title: const Text('Game Over'),
221+
content: Text('You lasted $_gameLength seconds'),
222+
actions: <Widget>[
223+
TextButton(
224+
onPressed: () {
225+
Navigator.pop(context);
226+
_interstitialAd?.show();
227+
},
228+
child: const Text('OK'),
235229
),
230+
],
231+
),
236232
);
237233
}
238234

samples/admob/mediation_example/lib/main.dart

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ class _MyHomePageState extends State<MyHomePage> {
8888
_bannerIsLoaded = true;
8989
});
9090
},
91-
onAdFailedToLoad:
92-
(ad, error) => debugPrint('$ad failed to load: ${error.message}'),
91+
onAdFailedToLoad: (ad, error) =>
92+
debugPrint('$ad failed to load: ${error.message}'),
9393
),
9494
request: AdRequest(nonPersonalizedAds: true),
9595
)..load();
@@ -100,13 +100,12 @@ class _MyHomePageState extends State<MyHomePage> {
100100

101101
return <Widget>[
102102
PopupMenuButton<AppBarItem>(
103-
itemBuilder:
104-
(BuildContext context) => <PopupMenuEntry<AppBarItem>>[
105-
PopupMenuItem<AppBarItem>(
106-
value: adInspectorMenuItem,
107-
child: Text(adInspectorMenuItem.label),
108-
),
109-
],
103+
itemBuilder: (BuildContext context) => <PopupMenuEntry<AppBarItem>>[
104+
PopupMenuItem<AppBarItem>(
105+
value: adInspectorMenuItem,
106+
child: Text(adInspectorMenuItem.label),
107+
),
108+
],
110109
onSelected: (item) {
111110
MobileAds.instance.openAdInspector((error) {
112111
// Error will be non-null if ad inspector closed due to an error.
@@ -131,10 +130,10 @@ class _MyHomePageState extends State<MyHomePage> {
131130
),
132131
_bannerIsLoaded && _bannerAd != null
133132
? Container(
134-
height: _bannerAd!.size.height.toDouble(),
135-
width: _bannerAd!.size.width.toDouble(),
136-
child: AdWidget(ad: _bannerAd!),
137-
)
133+
height: _bannerAd!.size.height.toDouble(),
134+
width: _bannerAd!.size.width.toDouble(),
135+
child: AdWidget(ad: _bannerAd!),
136+
)
138137
: Text('ad is not loaded'),
139138
],
140139
),

samples/admob/native_platform_example/lib/main.dart

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ class NativeExampleState extends State<NativeExample> {
2727
NativeAd? _nativeAd;
2828
bool _nativeAdIsLoaded = false;
2929

30-
final String _adUnitId =
31-
Platform.isAndroid
32-
? 'ca-app-pub-3940256099942544/2247696110'
33-
: 'ca-app-pub-3940256099942544/3986624511';
30+
final String _adUnitId = Platform.isAndroid
31+
? 'ca-app-pub-3940256099942544/2247696110'
32+
: 'ca-app-pub-3940256099942544/3986624511';
3433

3534
@override
3635
void initState() {
@@ -105,16 +104,14 @@ class NativeExampleState extends State<NativeExample> {
105104

106105
return <Widget>[
107106
PopupMenuButton<AppBarItem>(
108-
itemBuilder:
109-
(context) =>
110-
array
111-
.map(
112-
(item) => PopupMenuItem<AppBarItem>(
113-
value: item,
114-
child: Text(item.label),
115-
),
116-
)
117-
.toList(),
107+
itemBuilder: (context) => array
108+
.map(
109+
(item) => PopupMenuItem<AppBarItem>(
110+
value: item,
111+
child: Text(item.label),
112+
),
113+
)
114+
.toList(),
118115
onSelected: (item) {
119116
switch (item.value) {
120117
case 0:

samples/admob/native_template_example/lib/main.dart

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ class NativeExampleState extends State<NativeExample> {
2929
// final double _adAspectRatioSmall = (91 / 355);
3030
final double _adAspectRatioMedium = (370 / 355);
3131

32-
final String _adUnitId =
33-
Platform.isAndroid
34-
? 'ca-app-pub-3940256099942544/2247696110'
35-
: 'ca-app-pub-3940256099942544/3986624511';
32+
final String _adUnitId = Platform.isAndroid
33+
? 'ca-app-pub-3940256099942544/2247696110'
34+
: 'ca-app-pub-3940256099942544/3986624511';
3635

3736
@override
3837
void initState() {
@@ -113,16 +112,14 @@ class NativeExampleState extends State<NativeExample> {
113112

114113
return <Widget>[
115114
PopupMenuButton<AppBarItem>(
116-
itemBuilder:
117-
(context) =>
118-
array
119-
.map(
120-
(item) => PopupMenuItem<AppBarItem>(
121-
value: item,
122-
child: Text(item.label),
123-
),
124-
)
125-
.toList(),
115+
itemBuilder: (context) => array
116+
.map(
117+
(item) => PopupMenuItem<AppBarItem>(
118+
value: item,
119+
child: Text(item.label),
120+
),
121+
)
122+
.toList(),
126123
onSelected: (item) {
127124
switch (item.value) {
128125
case 0:

samples/admob/rewarded_example/lib/main.dart

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ class RewardedExampleState extends State<RewardedExample> {
3131
var _coins = 0;
3232
RewardedAd? _rewardedAd;
3333

34-
final String _adUnitId =
35-
Platform.isAndroid
36-
? 'ca-app-pub-3940256099942544/5224354917'
37-
: 'ca-app-pub-3940256099942544/1712485313';
34+
final String _adUnitId = Platform.isAndroid
35+
? 'ca-app-pub-3940256099942544/5224354917'
36+
: 'ca-app-pub-3940256099942544/1712485313';
3837

3938
@override
4039
void initState() {
@@ -145,14 +144,14 @@ class RewardedExampleState extends State<RewardedExample> {
145144
setState(() => _showWatchVideoButton = false);
146145

147146
_rewardedAd?.show(
148-
onUserEarnedReward: (
149-
AdWithoutView ad,
150-
RewardItem rewardItem,
151-
) {
152-
// ignore: avoid_print
153-
print('Reward amount: ${rewardItem.amount}');
154-
setState(() => _coins += rewardItem.amount.toInt());
155-
},
147+
onUserEarnedReward:
148+
(AdWithoutView ad, RewardItem rewardItem) {
149+
// ignore: avoid_print
150+
print('Reward amount: ${rewardItem.amount}');
151+
setState(
152+
() => _coins += rewardItem.amount.toInt(),
153+
);
154+
},
156155
);
157156
},
158157
child: const Text('Watch video for additional 10 coins'),
@@ -183,16 +182,14 @@ class RewardedExampleState extends State<RewardedExample> {
183182

184183
return <Widget>[
185184
PopupMenuButton<AppBarItem>(
186-
itemBuilder:
187-
(context) =>
188-
array
189-
.map(
190-
(item) => PopupMenuItem<AppBarItem>(
191-
value: item,
192-
child: Text(item.label),
193-
),
194-
)
195-
.toList(),
185+
itemBuilder: (context) => array
186+
.map(
187+
(item) => PopupMenuItem<AppBarItem>(
188+
value: item,
189+
child: Text(item.label),
190+
),
191+
)
192+
.toList(),
196193
onSelected: (item) {
197194
_pauseGame();
198195
switch (item.value) {

samples/admob/rewarded_interstitial_example/lib/main.dart

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ class RewardedInterstitialExampleState
3333
var _isPrivacyOptionsRequired = false;
3434
RewardedInterstitialAd? _rewardedInterstitialAd;
3535

36-
final String _adUnitId =
37-
Platform.isAndroid
38-
? 'ca-app-pub-3940256099942544/5354046379'
39-
: 'ca-app-pub-3940256099942544/6978759866';
36+
final String _adUnitId = Platform.isAndroid
37+
? 'ca-app-pub-3940256099942544/5354046379'
38+
: 'ca-app-pub-3940256099942544/6978759866';
4039

4140
@override
4241
void initState() {
@@ -69,13 +68,12 @@ class RewardedInterstitialExampleState
6968
if (_countdownTimer.isComplete) {
7069
showDialog(
7170
context: context,
72-
builder:
73-
(context) => AdDialog(
74-
showAd: () {
75-
_gameOver = true;
76-
_showAdCallback();
77-
},
78-
),
71+
builder: (context) => AdDialog(
72+
showAd: () {
73+
_gameOver = true;
74+
_showAdCallback();
75+
},
76+
),
7977
);
8078
_coins += 1;
8179
}
@@ -181,16 +179,14 @@ class RewardedInterstitialExampleState
181179

182180
return <Widget>[
183181
PopupMenuButton<AppBarItem>(
184-
itemBuilder:
185-
(context) =>
186-
array
187-
.map(
188-
(item) => PopupMenuItem<AppBarItem>(
189-
value: item,
190-
child: Text(item.label),
191-
),
192-
)
193-
.toList(),
182+
itemBuilder: (context) => array
183+
.map(
184+
(item) => PopupMenuItem<AppBarItem>(
185+
value: item,
186+
child: Text(item.label),
187+
),
188+
)
189+
.toList(),
194190
onSelected: (item) {
195191
_pauseGame();
196192
switch (item.value) {

0 commit comments

Comments
 (0)