From fe53867cea93235de2dc6c25e91ceb4f442cdec4 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Fri, 26 Apr 2024 14:55:23 -0400 Subject: [PATCH 01/14] Added UMP SDK integration to Interstitial example --- .../lib/consent_manager.dart | 50 +++++++++ .../admob/interstitial_example/lib/main.dart | 106 +++++++++++++++++- .../admob/interstitial_example/pubspec.yaml | 8 +- 3 files changed, 157 insertions(+), 7 deletions(-) create mode 100644 samples/admob/interstitial_example/lib/consent_manager.dart diff --git a/samples/admob/interstitial_example/lib/consent_manager.dart b/samples/admob/interstitial_example/lib/consent_manager.dart new file mode 100644 index 000000000..6f3d005da --- /dev/null +++ b/samples/admob/interstitial_example/lib/consent_manager.dart @@ -0,0 +1,50 @@ +import 'dart:async'; + +import 'package:google_mobile_ads/google_mobile_ads.dart'; + +typedef OnConsentGatheringCompleteListener = void Function(FormError? error); + +/// The Google Mobile Ads SDK provides the User Messaging Platform (Google's IAB +/// Certified consent management platform) as one solution to capture consent for +/// users in GDPR impacted countries. This is an example and you can choose +/// another consent management platform to capture consent. +class ConsentManager { + /// Helper variable to determine if the app can request ads. + Future canRequestAds() async { + return await ConsentInformation.instance.canRequestAds(); + } + + /// Helper variable to determine if the privacy options form is required. + Future isPrivacyOptionsRequired() async { + return await ConsentInformation.instance.getPrivacyOptionsRequirementStatus() + == PrivacyOptionsRequirementStatus.required; + } + + /// Helper method to call the Mobile Ads SDK to request consent information + /// and load/show a consent form if necessary. + void gatherConsent(OnConsentGatheringCompleteListener onConsentGatheringCompleteListener) { + // For testing purposes, you can force a DebugGeography of Eea or NotEea. + ConsentDebugSettings debugSettings = ConsentDebugSettings( + // debugGeography: DebugGeography.debugGeographyEea + ); + ConsentRequestParameters params = ConsentRequestParameters( + consentDebugSettings: debugSettings); + + // Requesting an update to consent information should be called on every app launch. + ConsentInformation.instance.requestConsentInfoUpdate( + params, + () async { + ConsentForm.loadAndShowConsentFormIfRequired((formError) { + // Consent has been gathered. + onConsentGatheringCompleteListener(formError); + }); + }, (FormError formError) { + onConsentGatheringCompleteListener(formError); + }); + } + + /// Helper method to call the Mobile Ads SDK method to show the privacy options form. + void showPrivacyOptionsForm(OnConsentFormDismissedListener onConsentFormDismissedListener) { + ConsentForm.showPrivacyOptionsForm(onConsentFormDismissedListener); + } +} \ No newline at end of file diff --git a/samples/admob/interstitial_example/lib/main.dart b/samples/admob/interstitial_example/lib/main.dart index 27269ec6c..98a313aa6 100644 --- a/samples/admob/interstitial_example/lib/main.dart +++ b/samples/admob/interstitial_example/lib/main.dart @@ -4,9 +4,10 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; +import 'consent_manager.dart'; + void main() { WidgetsFlutterBinding.ensureInitialized(); - MobileAds.instance.initialize(); runApp(const MaterialApp( home: InterstitialExample(), )); @@ -21,9 +22,16 @@ class InterstitialExample extends StatefulWidget { } class InterstitialExampleState extends State { + static const privacySettingsText = 'Privacy Settings'; + InterstitialAd? _interstitialAd; + final _consentManager = ConsentManager(); final _gameLength = 5; + var _gamePaused = false; + var _gameOver = false; + var _isMobileAdsInitializeCalled = false; late var _counter = _gameLength; + Timer? _timer; final String _adUnitId = Platform.isAndroid ? 'ca-app-pub-3940256099942544/1033173712' @@ -33,14 +41,45 @@ class InterstitialExampleState extends State { void initState() { super.initState(); - _startNewGame(); + _consentManager.gatherConsent((consentGatheringError) { + if (consentGatheringError != null) { + // Consent not obtained in current session. + debugPrint("${consentGatheringError.errorCode}: ${consentGatheringError.message}"); + } + + // Kick off the first play of the "game". + _startNewGame(); + + // Attempt to initialize the Mobile Ads SDK. + _initializeMobileAdsSDK(); + }); + + // This sample attempts to load ads using consent obtained in the previous session. + _initializeMobileAdsSDK(); } void _startNewGame() { setState(() => _counter = _gameLength); - _loadAd(); - _starTimer(); + _startTimer(); + _gameOver = false; + _gamePaused = false; + } + + void _pauseGame() { + if (_gameOver || _gamePaused) { + return; + } + _timer?.cancel(); + _gamePaused = true; + } + + void _resumeGame() { + if (_gameOver || !_gamePaused) { + return; + } + _startTimer(); + _gamePaused = false; } @override @@ -50,6 +89,32 @@ class InterstitialExampleState extends State { home: Scaffold( appBar: AppBar( title: const Text('Interstitial Example'), + actions: [ + // Regenerate the options menu to include a privacy setting. + FutureBuilder( + future: _consentManager.isPrivacyOptionsRequired(), + builder: (context, snapshot) { + final bool visibility = snapshot.data ?? false; + return Visibility( + visible: visibility, + child: PopupMenuButton( + onSelected: (String result) { + if (result == privacySettingsText) { + _pauseGame(); + _consentManager.showPrivacyOptionsForm((formError) { + if (formError != null) { + debugPrint("${formError.errorCode}: ${formError.message}"); + } + _resumeGame(); + }); + } + }, itemBuilder: (BuildContext context) => >[ + const PopupMenuItem( + value: privacySettingsText, + child: Text(privacySettingsText))], + )); + }) + ], ), body: Stack( children: [ @@ -74,6 +139,7 @@ class InterstitialExampleState extends State { child: TextButton( onPressed: () { _startNewGame(); + _loadAd(); }, child: const Text('Play Again'), ), @@ -87,6 +153,14 @@ class InterstitialExampleState extends State { /// Loads an interstitial ad. void _loadAd() { + // Only load an ad if the Mobile Ads SDK has gathered consent aligned with + // the app's configured messages. + _consentManager.canRequestAds().then((response) { + if (!response) { + return; + } + }); + InterstitialAd.load( adUnitId: _adUnitId, request: const AdRequest(), @@ -138,17 +212,37 @@ class InterstitialExampleState extends State { )); } - void _starTimer() { - Timer.periodic(const Duration(seconds: 1), (timer) { + void _startTimer() { + _timer = Timer.periodic(const Duration(seconds: 1), (timer) { setState(() => _counter--); if (_counter == 0) { + _gameOver = true; _showAlert(context); timer.cancel(); } }); } + /// Initialize the Mobile Ads SDK if the SDK has gathered consent aligned with + /// the app's configured messages. + void _initializeMobileAdsSDK() { + if (_isMobileAdsInitializeCalled) { + return; + } + + _consentManager.canRequestAds().then((response) { + if (response) { + _isMobileAdsInitializeCalled = true; + + // Initialize the Mobile Ads SDK. + MobileAds.instance.initialize(); + // Load an ad. + _loadAd(); + } + }); + } + @override void dispose() { _interstitialAd?.dispose(); diff --git a/samples/admob/interstitial_example/pubspec.yaml b/samples/admob/interstitial_example/pubspec.yaml index 1701dcb3e..c6a66fd0e 100644 --- a/samples/admob/interstitial_example/pubspec.yaml +++ b/samples/admob/interstitial_example/pubspec.yaml @@ -7,9 +7,15 @@ environment: sdk: '>=3.1.5 <4.0.0' dependencies: + google_mobile_ads: + git: + url: git@github.com:googleads/googleads-mobile-flutter/ + path: ./packages/google_mobile_ads + ref: umpUpdate + flutter: sdk: flutter - google_mobile_ads: ^4.0.0 + dev_dependencies: flutter_test: From e86b41c79bf9a3637c20b73efd0f63baf3c03bd1 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Fri, 26 Apr 2024 14:57:02 -0400 Subject: [PATCH 02/14] new line --- samples/admob/interstitial_example/lib/consent_manager.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/admob/interstitial_example/lib/consent_manager.dart b/samples/admob/interstitial_example/lib/consent_manager.dart index 6f3d005da..54343456c 100644 --- a/samples/admob/interstitial_example/lib/consent_manager.dart +++ b/samples/admob/interstitial_example/lib/consent_manager.dart @@ -47,4 +47,4 @@ class ConsentManager { void showPrivacyOptionsForm(OnConsentFormDismissedListener onConsentFormDismissedListener) { ConsentForm.showPrivacyOptionsForm(onConsentFormDismissedListener); } -} \ No newline at end of file +} From b14c9b3c65bba7e7879e95549834c248d4ffffc6 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Sat, 27 Apr 2024 14:05:33 -0400 Subject: [PATCH 03/14] Updated error name --- samples/admob/interstitial_example/lib/consent_manager.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/admob/interstitial_example/lib/consent_manager.dart b/samples/admob/interstitial_example/lib/consent_manager.dart index 54343456c..7e3e55823 100644 --- a/samples/admob/interstitial_example/lib/consent_manager.dart +++ b/samples/admob/interstitial_example/lib/consent_manager.dart @@ -25,7 +25,7 @@ class ConsentManager { void gatherConsent(OnConsentGatheringCompleteListener onConsentGatheringCompleteListener) { // For testing purposes, you can force a DebugGeography of Eea or NotEea. ConsentDebugSettings debugSettings = ConsentDebugSettings( - // debugGeography: DebugGeography.debugGeographyEea + // debugGeography: DebugGeography.debugGeographyEea ); ConsentRequestParameters params = ConsentRequestParameters( consentDebugSettings: debugSettings); @@ -34,9 +34,9 @@ class ConsentManager { ConsentInformation.instance.requestConsentInfoUpdate( params, () async { - ConsentForm.loadAndShowConsentFormIfRequired((formError) { + ConsentForm.loadAndShowConsentFormIfRequired((loadAndShowError) { // Consent has been gathered. - onConsentGatheringCompleteListener(formError); + onConsentGatheringCompleteListener(loadAndShowError); }); }, (FormError formError) { onConsentGatheringCompleteListener(formError); From 57f2f7f6bf51836bd2717d9536f328c9d997deb9 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Sat, 27 Apr 2024 17:27:35 -0400 Subject: [PATCH 04/14] formatted code --- .../lib/consent_manager.dart | 27 ++++++++++--------- .../admob/interstitial_example/lib/main.dart | 22 +++++++++------ 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/samples/admob/interstitial_example/lib/consent_manager.dart b/samples/admob/interstitial_example/lib/consent_manager.dart index 7e3e55823..4a46db3b4 100644 --- a/samples/admob/interstitial_example/lib/consent_manager.dart +++ b/samples/admob/interstitial_example/lib/consent_manager.dart @@ -16,35 +16,36 @@ class ConsentManager { /// Helper variable to determine if the privacy options form is required. Future isPrivacyOptionsRequired() async { - return await ConsentInformation.instance.getPrivacyOptionsRequirementStatus() - == PrivacyOptionsRequirementStatus.required; + return await ConsentInformation.instance + .getPrivacyOptionsRequirementStatus() == + PrivacyOptionsRequirementStatus.required; } /// Helper method to call the Mobile Ads SDK to request consent information /// and load/show a consent form if necessary. - void gatherConsent(OnConsentGatheringCompleteListener onConsentGatheringCompleteListener) { + void gatherConsent( + OnConsentGatheringCompleteListener onConsentGatheringCompleteListener) { // For testing purposes, you can force a DebugGeography of Eea or NotEea. - ConsentDebugSettings debugSettings = ConsentDebugSettings( - // debugGeography: DebugGeography.debugGeographyEea - ); - ConsentRequestParameters params = ConsentRequestParameters( - consentDebugSettings: debugSettings); + ConsentDebugSettings debugSettings = ConsentDebugSettings( + // debugGeography: DebugGeography.debugGeographyEea + ); + ConsentRequestParameters params = + ConsentRequestParameters(consentDebugSettings: debugSettings); // Requesting an update to consent information should be called on every app launch. - ConsentInformation.instance.requestConsentInfoUpdate( - params, - () async { + ConsentInformation.instance.requestConsentInfoUpdate(params, () async { ConsentForm.loadAndShowConsentFormIfRequired((loadAndShowError) { // Consent has been gathered. onConsentGatheringCompleteListener(loadAndShowError); }); }, (FormError formError) { - onConsentGatheringCompleteListener(formError); + onConsentGatheringCompleteListener(formError); }); } /// Helper method to call the Mobile Ads SDK method to show the privacy options form. - void showPrivacyOptionsForm(OnConsentFormDismissedListener onConsentFormDismissedListener) { + void showPrivacyOptionsForm( + OnConsentFormDismissedListener onConsentFormDismissedListener) { ConsentForm.showPrivacyOptionsForm(onConsentFormDismissedListener); } } diff --git a/samples/admob/interstitial_example/lib/main.dart b/samples/admob/interstitial_example/lib/main.dart index 98a313aa6..3c95d0785 100644 --- a/samples/admob/interstitial_example/lib/main.dart +++ b/samples/admob/interstitial_example/lib/main.dart @@ -44,7 +44,8 @@ class InterstitialExampleState extends State { _consentManager.gatherConsent((consentGatheringError) { if (consentGatheringError != null) { // Consent not obtained in current session. - debugPrint("${consentGatheringError.errorCode}: ${consentGatheringError.message}"); + debugPrint( + "${consentGatheringError.errorCode}: ${consentGatheringError.message}"); } // Kick off the first play of the "game". @@ -96,22 +97,27 @@ class InterstitialExampleState extends State { builder: (context, snapshot) { final bool visibility = snapshot.data ?? false; return Visibility( - visible: visibility, + visible: visibility, child: PopupMenuButton( onSelected: (String result) { if (result == privacySettingsText) { _pauseGame(); - _consentManager.showPrivacyOptionsForm((formError) { + _consentManager + .showPrivacyOptionsForm((formError) { if (formError != null) { - debugPrint("${formError.errorCode}: ${formError.message}"); + debugPrint( + "${formError.errorCode}: ${formError.message}"); } _resumeGame(); }); } - }, itemBuilder: (BuildContext context) => >[ - const PopupMenuItem( - value: privacySettingsText, - child: Text(privacySettingsText))], + }, + itemBuilder: (BuildContext context) => + >[ + const PopupMenuItem( + value: privacySettingsText, + child: Text(privacySettingsText)) + ], )); }) ], From 6971278ba0f2a1cd8b8302239fe09496603dd589 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Fri, 3 May 2024 14:28:39 -0400 Subject: [PATCH 05/14] spacing --- samples/admob/interstitial_example/lib/consent_manager.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/admob/interstitial_example/lib/consent_manager.dart b/samples/admob/interstitial_example/lib/consent_manager.dart index 4a46db3b4..c64afd1be 100644 --- a/samples/admob/interstitial_example/lib/consent_manager.dart +++ b/samples/admob/interstitial_example/lib/consent_manager.dart @@ -27,8 +27,8 @@ class ConsentManager { OnConsentGatheringCompleteListener onConsentGatheringCompleteListener) { // For testing purposes, you can force a DebugGeography of Eea or NotEea. ConsentDebugSettings debugSettings = ConsentDebugSettings( - // debugGeography: DebugGeography.debugGeographyEea - ); + // debugGeography: DebugGeography.debugGeographyEea, + ); ConsentRequestParameters params = ConsentRequestParameters(consentDebugSettings: debugSettings); From 633ca52e42cd99c612ed3c47eaf756b5fdb38844 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Fri, 3 May 2024 14:30:40 -0400 Subject: [PATCH 06/14] Removed branch --- samples/admob/interstitial_example/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/admob/interstitial_example/pubspec.yaml b/samples/admob/interstitial_example/pubspec.yaml index c6a66fd0e..d75211d54 100644 --- a/samples/admob/interstitial_example/pubspec.yaml +++ b/samples/admob/interstitial_example/pubspec.yaml @@ -11,7 +11,6 @@ dependencies: git: url: git@github.com:googleads/googleads-mobile-flutter/ path: ./packages/google_mobile_ads - ref: umpUpdate flutter: sdk: flutter From 178a6708b5aa5c5fedb7c8b3d13bef12d6a4cfe1 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Fri, 3 May 2024 14:41:43 -0400 Subject: [PATCH 07/14] https from ssh --- samples/admob/interstitial_example/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/admob/interstitial_example/pubspec.yaml b/samples/admob/interstitial_example/pubspec.yaml index d75211d54..98ffa8555 100644 --- a/samples/admob/interstitial_example/pubspec.yaml +++ b/samples/admob/interstitial_example/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: google_mobile_ads: git: - url: git@github.com:googleads/googleads-mobile-flutter/ + url: https://github.com/googleads/googleads-mobile-flutter/ path: ./packages/google_mobile_ads flutter: From 544288fe710b8f61f6debca8811e48dea1d174f9 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Fri, 3 May 2024 15:17:13 -0400 Subject: [PATCH 08/14] async/await --- .../admob/interstitial_example/lib/main.dart | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/samples/admob/interstitial_example/lib/main.dart b/samples/admob/interstitial_example/lib/main.dart index 3c95d0785..fd52b958b 100644 --- a/samples/admob/interstitial_example/lib/main.dart +++ b/samples/admob/interstitial_example/lib/main.dart @@ -158,14 +158,13 @@ class InterstitialExampleState extends State { } /// Loads an interstitial ad. - void _loadAd() { + void _loadAd() async { // Only load an ad if the Mobile Ads SDK has gathered consent aligned with // the app's configured messages. - _consentManager.canRequestAds().then((response) { - if (!response) { - return; - } - }); + var canRequestAds = await _consentManager.canRequestAds(); + if (!canRequestAds) { + return; + } InterstitialAd.load( adUnitId: _adUnitId, @@ -232,21 +231,20 @@ class InterstitialExampleState extends State { /// Initialize the Mobile Ads SDK if the SDK has gathered consent aligned with /// the app's configured messages. - void _initializeMobileAdsSDK() { + void _initializeMobileAdsSDK() async { if (_isMobileAdsInitializeCalled) { return; } - _consentManager.canRequestAds().then((response) { - if (response) { - _isMobileAdsInitializeCalled = true; + var canRequestAds = await _consentManager.canRequestAds(); + if (canRequestAds) { + _isMobileAdsInitializeCalled = true; - // Initialize the Mobile Ads SDK. - MobileAds.instance.initialize(); - // Load an ad. - _loadAd(); - } - }); + // Initialize the Mobile Ads SDK. + MobileAds.instance.initialize(); + // Load an ad. + _loadAd(); + } } @override From 722538bde53aeed657ce9cf7072ffc739c87767f Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Fri, 3 May 2024 16:21:19 -0400 Subject: [PATCH 09/14] Moved startnewgame out of consent callback --- samples/admob/interstitial_example/lib/main.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/admob/interstitial_example/lib/main.dart b/samples/admob/interstitial_example/lib/main.dart index fd52b958b..a79714760 100644 --- a/samples/admob/interstitial_example/lib/main.dart +++ b/samples/admob/interstitial_example/lib/main.dart @@ -48,15 +48,15 @@ class InterstitialExampleState extends State { "${consentGatheringError.errorCode}: ${consentGatheringError.message}"); } - // Kick off the first play of the "game". - _startNewGame(); - // Attempt to initialize the Mobile Ads SDK. _initializeMobileAdsSDK(); }); // This sample attempts to load ads using consent obtained in the previous session. _initializeMobileAdsSDK(); + + // Kick off the first play of the "game". + _startNewGame(); } void _startNewGame() { From 46d2b97a597f9a5f9b809272ba59bb27fba3bcd5 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Fri, 3 May 2024 16:24:11 -0400 Subject: [PATCH 10/14] put back --- samples/admob/interstitial_example/lib/main.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/admob/interstitial_example/lib/main.dart b/samples/admob/interstitial_example/lib/main.dart index a79714760..fd52b958b 100644 --- a/samples/admob/interstitial_example/lib/main.dart +++ b/samples/admob/interstitial_example/lib/main.dart @@ -48,15 +48,15 @@ class InterstitialExampleState extends State { "${consentGatheringError.errorCode}: ${consentGatheringError.message}"); } + // Kick off the first play of the "game". + _startNewGame(); + // Attempt to initialize the Mobile Ads SDK. _initializeMobileAdsSDK(); }); // This sample attempts to load ads using consent obtained in the previous session. _initializeMobileAdsSDK(); - - // Kick off the first play of the "game". - _startNewGame(); } void _startNewGame() { From a83a9f06883c2a1376ca9435c7833aeaff413924 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Mon, 6 May 2024 14:08:25 -0400 Subject: [PATCH 11/14] updated app bar action --- .../admob/interstitial_example/lib/main.dart | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/samples/admob/interstitial_example/lib/main.dart b/samples/admob/interstitial_example/lib/main.dart index fd52b958b..ee92d17dc 100644 --- a/samples/admob/interstitial_example/lib/main.dart +++ b/samples/admob/interstitial_example/lib/main.dart @@ -90,37 +90,9 @@ class InterstitialExampleState extends State { home: Scaffold( appBar: AppBar( title: const Text('Interstitial Example'), - actions: [ - // Regenerate the options menu to include a privacy setting. - FutureBuilder( - future: _consentManager.isPrivacyOptionsRequired(), - builder: (context, snapshot) { - final bool visibility = snapshot.data ?? false; - return Visibility( - visible: visibility, - child: PopupMenuButton( - onSelected: (String result) { - if (result == privacySettingsText) { - _pauseGame(); - _consentManager - .showPrivacyOptionsForm((formError) { - if (formError != null) { - debugPrint( - "${formError.errorCode}: ${formError.message}"); - } - _resumeGame(); - }); - } - }, - itemBuilder: (BuildContext context) => - >[ - const PopupMenuItem( - value: privacySettingsText, - child: Text(privacySettingsText)) - ], - )); - }) - ], + actions: _isMobileAdsInitializeCalled + ? _privacySettingsAppBarAction() + : null, ), body: Stack( children: [ @@ -157,6 +129,39 @@ class InterstitialExampleState extends State { ); } + List _privacySettingsAppBarAction() { + return [ + // Regenerate the options menu to include a privacy setting. + FutureBuilder( + future: _consentManager.isPrivacyOptionsRequired(), + builder: (context, snapshot) { + final bool visibility = snapshot.data ?? false; + return Visibility( + visible: visibility, + child: PopupMenuButton( + onSelected: (String result) { + if (result == privacySettingsText) { + _pauseGame(); + _consentManager.showPrivacyOptionsForm((formError) { + if (formError != null) { + debugPrint( + "${formError.errorCode}: ${formError.message}"); + } + _resumeGame(); + }); + } + }, + itemBuilder: (BuildContext context) => + >[ + const PopupMenuItem( + value: privacySettingsText, + child: Text(privacySettingsText)) + ], + )); + }) + ]; + } + /// Loads an interstitial ad. void _loadAd() async { // Only load an ad if the Mobile Ads SDK has gathered consent aligned with From a296499898b4f2f979b7ebb71474166ac225ca05 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Mon, 6 May 2024 14:20:18 -0400 Subject: [PATCH 12/14] setState --- samples/admob/interstitial_example/lib/main.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/admob/interstitial_example/lib/main.dart b/samples/admob/interstitial_example/lib/main.dart index ee92d17dc..7ba3528b7 100644 --- a/samples/admob/interstitial_example/lib/main.dart +++ b/samples/admob/interstitial_example/lib/main.dart @@ -243,7 +243,9 @@ class InterstitialExampleState extends State { var canRequestAds = await _consentManager.canRequestAds(); if (canRequestAds) { - _isMobileAdsInitializeCalled = true; + setState(() { + _isMobileAdsInitializeCalled = true; + }); // Initialize the Mobile Ads SDK. MobileAds.instance.initialize(); From 59be490ded59ae089dfdd4fb0ac6d60df598829c Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Thu, 9 May 2024 10:25:36 -0400 Subject: [PATCH 13/14] Using 5.1.0 --- samples/admob/interstitial_example/pubspec.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/samples/admob/interstitial_example/pubspec.yaml b/samples/admob/interstitial_example/pubspec.yaml index 98ffa8555..804170b1a 100644 --- a/samples/admob/interstitial_example/pubspec.yaml +++ b/samples/admob/interstitial_example/pubspec.yaml @@ -7,13 +7,9 @@ environment: sdk: '>=3.1.5 <4.0.0' dependencies: - google_mobile_ads: - git: - url: https://github.com/googleads/googleads-mobile-flutter/ - path: ./packages/google_mobile_ads - flutter: sdk: flutter + google_mobile_ads: ^5.1.0 dev_dependencies: From 64315c9cba6f8b0d32bda381ae5c9d1696857671 Mon Sep 17 00:00:00 2001 From: Justin Malandruccolo Date: Thu, 9 May 2024 10:26:04 -0400 Subject: [PATCH 14/14] space --- samples/admob/interstitial_example/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/admob/interstitial_example/pubspec.yaml b/samples/admob/interstitial_example/pubspec.yaml index 804170b1a..7844263e7 100644 --- a/samples/admob/interstitial_example/pubspec.yaml +++ b/samples/admob/interstitial_example/pubspec.yaml @@ -11,7 +11,6 @@ dependencies: sdk: flutter google_mobile_ads: ^5.1.0 - dev_dependencies: flutter_test: sdk: flutter