From 0bac379052cd8c482ba55aec2974819757399ff7 Mon Sep 17 00:00:00 2001 From: x-wei Date: Sun, 21 Apr 2024 11:03:34 +0200 Subject: [PATCH] fixup --- lib/firebase_options.dart | 9 ++++--- lib/routes/appbar_search_ex.dart | 2 +- lib/routes/firebase_mlkit_ex.dart | 6 ++--- .../monetization_adaptive_banner_ad_ex.dart | 25 +++---------------- .../monetization_bottom_banner_ad_ex.dart | 2 +- .../monetization_inline_banner_ad_ex.dart | 2 +- .../monetization_interstitial_ad_ex.dart | 4 +-- lib/routes/monetization_rewarded_ad_ex.dart | 4 +-- lib/routes/networking_rest_api_send_ex.dart | 2 +- lib/routes/plugins_local_auth_ex.dart | 4 +-- 10 files changed, 22 insertions(+), 38 deletions(-) diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart index 7657192..d85fa0f 100644 --- a/lib/firebase_options.dart +++ b/lib/firebase_options.dart @@ -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', ); - -} \ No newline at end of file +} diff --git a/lib/routes/appbar_search_ex.dart b/lib/routes/appbar_search_ex.dart index 374cf35..5aed7ba 100644 --- a/lib/routes/appbar_search_ex.dart +++ b/lib/routes/appbar_search_ex.dart @@ -42,7 +42,7 @@ class _AppBarSearchExampleState extends State { 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'), diff --git a/lib/routes/firebase_mlkit_ex.dart b/lib/routes/firebase_mlkit_ex.dart index 4e74256..bef96fa 100644 --- a/lib/routes/firebase_mlkit_ex.dart +++ b/lib/routes/firebase_mlkit_ex.dart @@ -32,7 +32,7 @@ class _GoogleMLKitExampleState extends State { 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)); } }, @@ -44,12 +44,12 @@ class _GoogleMLKitExampleState extends State { 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); } }, ), diff --git a/lib/routes/monetization_adaptive_banner_ad_ex.dart b/lib/routes/monetization_adaptive_banner_ad_ex.dart index df0734a..7fa8451 100644 --- a/lib/routes/monetization_adaptive_banner_ad_ex.dart +++ b/lib/routes/monetization_adaptive_banner_ad_ex.dart @@ -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}); @@ -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(); @@ -50,7 +33,7 @@ class _AnchoredAdaptiveBannerAdExampleState return; } _bannerAd = BannerAd( - adUnitId: _kAdUnitId, + adUnitId: MySecretsHelper.bannerAdUnitId, size: size, request: AdRequest(), listener: BannerAdListener( @@ -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 diff --git a/lib/routes/monetization_bottom_banner_ad_ex.dart b/lib/routes/monetization_bottom_banner_ad_ex.dart index bd23d5d..969502f 100644 --- a/lib/routes/monetization_bottom_banner_ad_ex.dart +++ b/lib/routes/monetization_bottom_banner_ad_ex.dart @@ -48,7 +48,7 @@ class _BottomBannerAdExampleState extends State { 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. diff --git a/lib/routes/monetization_inline_banner_ad_ex.dart b/lib/routes/monetization_inline_banner_ad_ex.dart index b896ee1..6382b1d 100644 --- a/lib/routes/monetization_inline_banner_ad_ex.dart +++ b/lib/routes/monetization_inline_banner_ad_ex.dart @@ -12,7 +12,7 @@ class InlineBannerAdExample extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - const Text( + const SelectableText( ''' Inline banners\n\n diff --git a/lib/routes/monetization_interstitial_ad_ex.dart b/lib/routes/monetization_interstitial_ad_ex.dart index 2854f79..648f2b3 100644 --- a/lib/routes/monetization_interstitial_ad_ex.dart +++ b/lib/routes/monetization_interstitial_ad_ex.dart @@ -77,7 +77,7 @@ class _InterstitialAdExampleState extends State { 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. @@ -101,7 +101,7 @@ class _InterstitialAdExampleState extends State { ? null : () async { final adShown = await _showInterstitialAd(); - if (!mounted) return; + if (!context.mounted) return; if (adShown) { Navigator.push( context, diff --git a/lib/routes/monetization_rewarded_ad_ex.dart b/lib/routes/monetization_rewarded_ad_ex.dart index ed6e6e2..0a8262e 100644 --- a/lib/routes/monetization_rewarded_ad_ex.dart +++ b/lib/routes/monetization_rewarded_ad_ex.dart @@ -101,7 +101,7 @@ class _RewordedAdExampleState extends ConsumerState { 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. @@ -123,7 +123,7 @@ class _RewordedAdExampleState extends ConsumerState { ? 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!')), diff --git a/lib/routes/networking_rest_api_send_ex.dart b/lib/routes/networking_rest_api_send_ex.dart index cf31f3c..e8b5890 100644 --- a/lib/routes/networking_rest_api_send_ex.dart +++ b/lib/routes/networking_rest_api_send_ex.dart @@ -32,7 +32,7 @@ class _RestApiSendExampleState extends State { return ListView( padding: const EdgeInsets.all(16.0), children: [ - const Text( + const SelectableText( ''' In this example we will POST to the jsonplaceholder API. diff --git a/lib/routes/plugins_local_auth_ex.dart b/lib/routes/plugins_local_auth_ex.dart index ad79b37..f94655d 100644 --- a/lib/routes/plugins_local_auth_ex.dart +++ b/lib/routes/plugins_local_auth_ex.dart @@ -23,7 +23,7 @@ class _LocalAuthExampleState extends State { Future _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( @@ -50,7 +50,7 @@ class _LocalAuthExampleState extends State { } return authSuccess; } catch (e) { - if (context.mounted) { + if (mounted) { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text(e.toString())), );