Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Wei committed Apr 21, 2024
1 parent fe91059 commit 0bac379
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 38 deletions.
9 changes: 5 additions & 4 deletions lib/firebase_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ class DefaultFirebaseOptions {
projectId: 'flutter-catalog',
databaseURL: 'https://flutter-catalog.firebaseio.com',
storageBucket: 'flutter-catalog.appspot.com',
androidClientId: '785184947614-jvcu7agpj6n6vvr5poal14otu8mjdl61.apps.googleusercontent.com',
iosClientId: '785184947614-70ii5qm94fe28nmasjc9g864nh25l4m7.apps.googleusercontent.com',
androidClientId:
'785184947614-jvcu7agpj6n6vvr5poal14otu8mjdl61.apps.googleusercontent.com',
iosClientId:
'785184947614-70ii5qm94fe28nmasjc9g864nh25l4m7.apps.googleusercontent.com',
iosBundleId: 'io.github.x-wei.flutter-catalog',
);

}
}
2 changes: 1 addition & 1 deletion lib/routes/appbar_search_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _AppBarSearchExampleState extends State<AppBarSearchExample> {
context: context,
delegate: _delegate,
);
if (mounted && selected != null) {
if (context.mounted && selected != null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('You have selected the word: $selected'),
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/firebase_mlkit_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class _GoogleMLKitExampleState extends State<GoogleMLKitExample> {
onTap: () async {
final XFile? pickedFile =
await _picker.pickImage(source: ImageSource.camera);
if (mounted && pickedFile != null) {
if (ctx.mounted && pickedFile != null) {
Navigator.pop(ctx, File(pickedFile.path));
}
},
Expand All @@ -44,12 +44,12 @@ class _GoogleMLKitExampleState extends State<GoogleMLKitExample> {
try {
final XFile? pickedFile =
await _picker.pickImage(source: ImageSource.gallery);
if (mounted && pickedFile != null) {
if (ctx.mounted && pickedFile != null) {
Navigator.pop(ctx, File(pickedFile.path));
}
} catch (e) {
print(e);
if (mounted) Navigator.pop(ctx, null);
if (ctx.mounted) Navigator.pop(ctx, null);
}
},
),
Expand Down
25 changes: 4 additions & 21 deletions lib/routes/monetization_adaptive_banner_ad_ex.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';

import 'feature_store_secrets.dart';

class AnchoredAdaptiveBannerAdExample extends StatefulWidget {
const AnchoredAdaptiveBannerAdExample({super.key});

Expand All @@ -17,22 +16,6 @@ class _AnchoredAdaptiveBannerAdExampleState
bool _adLoaded = false;
BannerAd? _bannerAd;

String get _kAdUnitId {
// ! Return test ad unit if we are in debug mode -- otherwise account might be banned!
if (Platform.isAndroid) {
return kDebugMode
// https://developers.google.com/admob/android/test-ads#sample_ad_units
? 'ca-app-pub-3940256099942544/6300978111'
: 'ca-app-pub-7906158617398863/4414540775';
} else if (Platform.isIOS) {
return kDebugMode
// https://developers.google.com/admob/ios/test-ads#demo_ad_units
? 'ca-app-pub-3940256099942544/2934735716'
: 'ca-app-pub-7906158617398863/5234412829';
}
return '';
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
Expand All @@ -50,7 +33,7 @@ class _AnchoredAdaptiveBannerAdExampleState
return;
}
_bannerAd = BannerAd(
adUnitId: _kAdUnitId,
adUnitId: MySecretsHelper.bannerAdUnitId,
size: size,
request: AdRequest(),
listener: BannerAdListener(
Expand All @@ -76,7 +59,7 @@ class _AnchoredAdaptiveBannerAdExampleState
body: Container(
alignment: Alignment.center,
padding: const EdgeInsets.all(8),
child: const Text(
child: const SelectableText(
'''
Anchored adaptive banners\n\n
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/monetization_bottom_banner_ad_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class _BottomBannerAdExampleState extends State<BottomBannerAdExample> {
body: Container(
alignment: Alignment.center,
padding: const EdgeInsets.all(8),
child: const Text(
child: const SelectableText(
'''
Botton banner ad.\n\n
Banner ads occupy a spot within an app's layout, either at the top or bottom of the device screen. They stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time.
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/monetization_inline_banner_ad_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class InlineBannerAdExample extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: [
const Text(
const SelectableText(
'''
Inline banners\n\n
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/monetization_interstitial_ad_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class _InterstitialAdExampleState extends State<InterstitialAdExample> {
return ListView(
padding: const EdgeInsets.all(8),
children: [
Text(
SelectableText(
'''
Interstitial ad.\n
Interstitial ads are full-screen ads that cover the interface of their host app. They're typically displayed at natural transition points in the flow of an app, such as between activities or during the pause between levels in a game. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.
Expand All @@ -101,7 +101,7 @@ class _InterstitialAdExampleState extends State<InterstitialAdExample> {
? null
: () async {
final adShown = await _showInterstitialAd();
if (!mounted) return;
if (!context.mounted) return;
if (adShown) {
Navigator.push(
context,
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/monetization_rewarded_ad_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class _RewordedAdExampleState extends ConsumerState<RewordedAdExample> {
return ListView(
padding: const EdgeInsets.all(8),
children: [
Text(
SelectableText(
'''
Rewarded ad.\n
Rewarded ads are ads that users have the option of interacting with in exchange for in-app rewards.
Expand All @@ -123,7 +123,7 @@ class _RewordedAdExampleState extends ConsumerState<RewordedAdExample> {
? null
: () async {
final adShown = await _showRewardedAd();
if (!adShown && mounted) {
if (!adShown && context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Ad not displayed, please retry!')),
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/networking_rest_api_send_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class _RestApiSendExampleState extends State<RestApiSendExample> {
return ListView(
padding: const EdgeInsets.all(16.0),
children: <Widget>[
const Text(
const SelectableText(
'''
In this example we will POST to the jsonplaceholder API.
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/plugins_local_auth_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class _LocalAuthExampleState extends State<LocalAuthExample> {
Future<bool> _auth() async {
setState(() => this._authSuccess = false);
if (await this._localAuth.canCheckBiometrics == false) {
if (context.mounted) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
Expand All @@ -50,7 +50,7 @@ class _LocalAuthExampleState extends State<LocalAuthExample> {
}
return authSuccess;
} catch (e) {
if (context.mounted) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(e.toString())),
);
Expand Down

0 comments on commit 0bac379

Please sign in to comment.