From 728de54c221438d1d755f5fa7ead21b7f2e242b7 Mon Sep 17 00:00:00 2001
From: Bhargav Raviya <46953122+bhargavraviya@users.noreply.github.com>
Date: Tue, 28 Oct 2025 20:10:12 +0530
Subject: [PATCH 001/251] Upgrade Flutter Version - Sample Rewarded (#1348)
---
samples/admob/rewarded_example/.gitignore | 2 +-
samples/admob/rewarded_example/.metadata | 13 ++--
.../admob/rewarded_example/android/.gitignore | 3 +-
.../rewarded_example/android/app/build.gradle | 70 -------------------
.../android/app/build.gradle.kts | 44 ++++++++++++
.../android/app/src/main/AndroidManifest.xml | 12 ++++
.../example/rewarded_example/MainActivity.kt | 3 +-
.../rewarded_example/android/build.gradle | 18 -----
.../rewarded_example/android/build.gradle.kts | 24 +++++++
.../android/gradle.properties | 2 +-
.../gradle/wrapper/gradle-wrapper.properties | 2 +-
.../rewarded_example/android/settings.gradle | 25 -------
.../android/settings.gradle.kts | 26 +++++++
samples/admob/rewarded_example/pubspec.yaml | 4 +-
14 files changed, 119 insertions(+), 129 deletions(-)
delete mode 100644 samples/admob/rewarded_example/android/app/build.gradle
create mode 100644 samples/admob/rewarded_example/android/app/build.gradle.kts
delete mode 100644 samples/admob/rewarded_example/android/build.gradle
create mode 100644 samples/admob/rewarded_example/android/build.gradle.kts
delete mode 100644 samples/admob/rewarded_example/android/settings.gradle
create mode 100644 samples/admob/rewarded_example/android/settings.gradle.kts
diff --git a/samples/admob/rewarded_example/.gitignore b/samples/admob/rewarded_example/.gitignore
index 79c113f9b..3820a95c6 100644
--- a/samples/admob/rewarded_example/.gitignore
+++ b/samples/admob/rewarded_example/.gitignore
@@ -27,11 +27,11 @@ migrate_working_dir/
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
-.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/
+/coverage/
# Symbolication related
app.*.symbols
diff --git a/samples/admob/rewarded_example/.metadata b/samples/admob/rewarded_example/.metadata
index 6c1bf2fff..380380670 100644
--- a/samples/admob/rewarded_example/.metadata
+++ b/samples/admob/rewarded_example/.metadata
@@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.
version:
- revision: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a"
+ revision: "a402d9a4376add5bc2d6b1e33e53edaae58c07f8"
channel: "stable"
project_type: app
@@ -13,14 +13,11 @@ project_type: app
migration:
platforms:
- platform: root
- create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
+ create_revision: a402d9a4376add5bc2d6b1e33e53edaae58c07f8
+ base_revision: a402d9a4376add5bc2d6b1e33e53edaae58c07f8
- platform: android
- create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- - platform: ios
- create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
+ create_revision: a402d9a4376add5bc2d6b1e33e53edaae58c07f8
+ base_revision: a402d9a4376add5bc2d6b1e33e53edaae58c07f8
# User provided section
diff --git a/samples/admob/rewarded_example/android/.gitignore b/samples/admob/rewarded_example/android/.gitignore
index 6f568019d..be3943c96 100644
--- a/samples/admob/rewarded_example/android/.gitignore
+++ b/samples/admob/rewarded_example/android/.gitignore
@@ -5,9 +5,10 @@ gradle-wrapper.jar
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
+.cxx/
# Remember to never publicly share your keystore.
-# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
+# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
diff --git a/samples/admob/rewarded_example/android/app/build.gradle b/samples/admob/rewarded_example/android/app/build.gradle
deleted file mode 100644
index f9b5a4f56..000000000
--- a/samples/admob/rewarded_example/android/app/build.gradle
+++ /dev/null
@@ -1,70 +0,0 @@
-plugins {
- id "com.android.application"
- id "kotlin-android"
- id "dev.flutter.flutter-gradle-plugin"
-}
-
-def localProperties = new Properties()
-def localPropertiesFile = rootProject.file('local.properties')
-if (localPropertiesFile.exists()) {
- localPropertiesFile.withReader('UTF-8') { reader ->
- localProperties.load(reader)
- }
-}
-
-def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
-if (flutterVersionCode == null) {
- flutterVersionCode = '1'
-}
-
-def flutterVersionName = localProperties.getProperty('flutter.versionName')
-if (flutterVersionName == null) {
- flutterVersionName = '1.0'
-}
-
-android {
- namespace "com.example.rewarded_example"
- compileSdkVersion flutter.compileSdkVersion
- ndkVersion = flutter.ndkVersion
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- kotlinOptions {
- jvmTarget = '1.8'
- }
-
- sourceSets {
- main.java.srcDirs += 'src/main/kotlin'
- }
-
- defaultConfig {
- // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
- applicationId "com.example.rewarded_example"
- // You can update the following values to match your application needs.
- // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
- minSdkVersion 23
- multiDexEnabled true
- targetSdkVersion flutter.targetSdkVersion
- versionCode flutterVersionCode.toInteger()
- versionName flutterVersionName
- }
-
- buildTypes {
- release {
- // TODO: Add your own signing config for the release build.
- // Signing with the debug keys for now, so `flutter run --release` works.
- signingConfig signingConfigs.debug
- }
- }
-}
-
-flutter {
- source '../..'
-}
-
-dependencies {
- implementation 'androidx.multidex:multidex:2.0.1'
-}
diff --git a/samples/admob/rewarded_example/android/app/build.gradle.kts b/samples/admob/rewarded_example/android/app/build.gradle.kts
new file mode 100644
index 000000000..51e2ee1ef
--- /dev/null
+++ b/samples/admob/rewarded_example/android/app/build.gradle.kts
@@ -0,0 +1,44 @@
+plugins {
+ id("com.android.application")
+ id("kotlin-android")
+ // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
+ id("dev.flutter.flutter-gradle-plugin")
+}
+
+android {
+ namespace = "com.example.rewarded_example"
+ compileSdk = flutter.compileSdkVersion
+ ndkVersion = flutter.ndkVersion
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_11
+ targetCompatibility = JavaVersion.VERSION_11
+ }
+
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_11.toString()
+ }
+
+ defaultConfig {
+ // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
+ applicationId = "com.example.rewarded_example"
+ // You can update the following values to match your application needs.
+ // For more information, see: https://flutter.dev/to/review-gradle-config.
+ minSdk = flutter.minSdkVersion
+ targetSdk = flutter.targetSdkVersion
+ versionCode = flutter.versionCode
+ versionName = flutter.versionName
+ }
+
+ buildTypes {
+ release {
+ // TODO: Add your own signing config for the release build.
+ // Signing with the debug keys for now, so `flutter run --release` works.
+ signingConfig = signingConfigs.getByName("debug")
+ }
+ }
+}
+
+flutter {
+ source = "../.."
+}
diff --git a/samples/admob/rewarded_example/android/app/src/main/AndroidManifest.xml b/samples/admob/rewarded_example/android/app/src/main/AndroidManifest.xml
index 0330b55bf..64d1cfabf 100644
--- a/samples/admob/rewarded_example/android/app/src/main/AndroidManifest.xml
+++ b/samples/admob/rewarded_example/android/app/src/main/AndroidManifest.xml
@@ -7,6 +7,7 @@
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
+ android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
@@ -33,4 +34,15 @@
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
+
+
+
+
+
+
+
diff --git a/samples/admob/rewarded_example/android/app/src/main/kotlin/com/example/rewarded_example/MainActivity.kt b/samples/admob/rewarded_example/android/app/src/main/kotlin/com/example/rewarded_example/MainActivity.kt
index e6f3f6c17..9fb470511 100644
--- a/samples/admob/rewarded_example/android/app/src/main/kotlin/com/example/rewarded_example/MainActivity.kt
+++ b/samples/admob/rewarded_example/android/app/src/main/kotlin/com/example/rewarded_example/MainActivity.kt
@@ -2,5 +2,4 @@ package com.example.rewarded_example
import io.flutter.embedding.android.FlutterActivity
-class MainActivity: FlutterActivity() {
-}
+class MainActivity : FlutterActivity()
diff --git a/samples/admob/rewarded_example/android/build.gradle b/samples/admob/rewarded_example/android/build.gradle
deleted file mode 100644
index bc157bd1a..000000000
--- a/samples/admob/rewarded_example/android/build.gradle
+++ /dev/null
@@ -1,18 +0,0 @@
-allprojects {
- repositories {
- google()
- mavenCentral()
- }
-}
-
-rootProject.buildDir = '../build'
-subprojects {
- project.buildDir = "${rootProject.buildDir}/${project.name}"
-}
-subprojects {
- project.evaluationDependsOn(':app')
-}
-
-tasks.register("clean", Delete) {
- delete rootProject.buildDir
-}
diff --git a/samples/admob/rewarded_example/android/build.gradle.kts b/samples/admob/rewarded_example/android/build.gradle.kts
new file mode 100644
index 000000000..dbee657bb
--- /dev/null
+++ b/samples/admob/rewarded_example/android/build.gradle.kts
@@ -0,0 +1,24 @@
+allprojects {
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+
+val newBuildDir: Directory =
+ rootProject.layout.buildDirectory
+ .dir("../../build")
+ .get()
+rootProject.layout.buildDirectory.value(newBuildDir)
+
+subprojects {
+ val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
+ project.layout.buildDirectory.value(newSubprojectBuildDir)
+}
+subprojects {
+ project.evaluationDependsOn(":app")
+}
+
+tasks.register("clean") {
+ delete(rootProject.layout.buildDirectory)
+}
diff --git a/samples/admob/rewarded_example/android/gradle.properties b/samples/admob/rewarded_example/android/gradle.properties
index 598d13fee..f018a6181 100644
--- a/samples/admob/rewarded_example/android/gradle.properties
+++ b/samples/admob/rewarded_example/android/gradle.properties
@@ -1,3 +1,3 @@
-org.gradle.jvmargs=-Xmx4G
+org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
diff --git a/samples/admob/rewarded_example/android/gradle/wrapper/gradle-wrapper.properties b/samples/admob/rewarded_example/android/gradle/wrapper/gradle-wrapper.properties
index 3c85cfe05..ac3b47926 100644
--- a/samples/admob/rewarded_example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/samples/admob/rewarded_example/android/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
diff --git a/samples/admob/rewarded_example/android/settings.gradle b/samples/admob/rewarded_example/android/settings.gradle
deleted file mode 100644
index f4e0879bf..000000000
--- a/samples/admob/rewarded_example/android/settings.gradle
+++ /dev/null
@@ -1,25 +0,0 @@
-pluginManagement {
- def flutterSdkPath = {
- def properties = new Properties()
- file("local.properties").withInputStream { properties.load(it) }
- def flutterSdkPath = properties.getProperty("flutter.sdk")
- assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
- return flutterSdkPath
- }()
-
- includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
-
- repositories {
- google()
- mavenCentral()
- gradlePluginPortal()
- }
-}
-
-plugins {
- id "dev.flutter.flutter-plugin-loader" version "1.0.0"
- id "com.android.application" version "8.6.0" apply false
- id "org.jetbrains.kotlin.android" version "2.1.0" apply false
-}
-
-include ":app"
\ No newline at end of file
diff --git a/samples/admob/rewarded_example/android/settings.gradle.kts b/samples/admob/rewarded_example/android/settings.gradle.kts
new file mode 100644
index 000000000..fb605bc84
--- /dev/null
+++ b/samples/admob/rewarded_example/android/settings.gradle.kts
@@ -0,0 +1,26 @@
+pluginManagement {
+ val flutterSdkPath =
+ run {
+ val properties = java.util.Properties()
+ file("local.properties").inputStream().use { properties.load(it) }
+ val flutterSdkPath = properties.getProperty("flutter.sdk")
+ require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
+ flutterSdkPath
+ }
+
+ includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
+
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+
+plugins {
+ id("dev.flutter.flutter-plugin-loader") version "1.0.0"
+ id("com.android.application") version "8.9.1" apply false
+ id("org.jetbrains.kotlin.android") version "2.1.0" apply false
+}
+
+include(":app")
diff --git a/samples/admob/rewarded_example/pubspec.yaml b/samples/admob/rewarded_example/pubspec.yaml
index dcf785aa7..1e8813fc3 100644
--- a/samples/admob/rewarded_example/pubspec.yaml
+++ b/samples/admob/rewarded_example/pubspec.yaml
@@ -1,10 +1,10 @@
name: rewarded_example
-description: Example project for demoing rewarded ads.
+description: "Example project for demoing rewarded ads."
publish_to: 'none'
version: 1.0.0+1
environment:
- sdk: '>=3.2.0 <4.0.0'
+ sdk: ^3.9.2
dependencies:
flutter:
From 675aa0add29e6163ddcce3f32959ac4b2426f86b Mon Sep 17 00:00:00 2001
From: LTphantom
Date: Tue, 16 Dec 2025 11:21:45 -0800
Subject: [PATCH 002/251] GMA SDK major version update 7.0.0 (#1369)
* Fix Native Ads templates
* Updated iOS project, updated inline banner ad unit in example app
* Correctly set new low bounds for Flutter and Dart versions
* Updated minSdk for Android to make it compatible with Flutter versions
* Format fix
* Added more contraints on Native Ad template to avoid unexpected button behaviors
* Made the release a major release (7.0.0)
* Updated Android GMA SDK to 24.9.0
* Modified layout contraints to let CTA button in Native Ad to not be pushed away
---
packages/google_mobile_ads/CHANGELOG.md | 11 +
.../google_mobile_ads/android/build.gradle | 39 +-
.../gradle/wrapper/gradle-wrapper.properties | 4 +-
.../plugins/googlemobileads/Constants.java | 2 +-
.../res/layout/gnt_medium_template_view.xml | 9 +-
.../res/layout/gnt_small_template_view.xml | 9 +-
.../example/android/app/build.gradle | 4 +-
.../example/android/gradle.properties | 2 +-
.../gradle/wrapper/gradle-wrapper.properties | 4 +-
.../example/android/settings.gradle | 4 +-
.../ios/Flutter/AppFrameworkInfo.plist | 2 +-
.../google_mobile_ads/example/ios/Podfile | 2 +-
.../ios/Runner.xcodeproj/project.pbxproj | 134 +-
.../lib/anchored_adaptive_example.dart | 48 +-
.../example/lib/fluid_example.dart | 83 +-
.../example/lib/inline_adaptive_example.dart | 61 +-
.../google_mobile_ads/example/lib/main.dart | 413 +++---
..._adaptive_inline_with_recycle_example.dart | 60 +-
.../example/lib/native_template_example.dart | 68 +-
.../example/lib/reusable_inline_example.dart | 121 +-
.../lib/snippets/banner_ad_snippets.dart | 40 +-
.../snippets/interstitial_ad_snippets.dart | 6 +-
.../lib/snippets/rewarded_ad_snippets.dart | 12 +-
.../rewarded_interstitial_ad_snippets.dart | 12 +-
.../example/lib/webview_example.dart | 12 +-
.../google_mobile_ads/example/pubspec.yaml | 4 +-
.../ios/Classes/FLTConstants.h | 2 +-
.../ios/google_mobile_ads.podspec | 4 +-
.../lib/src/ad_containers.dart | 306 +++--
.../lib/src/ad_inspector_containers.dart | 6 +-
.../lib/src/ad_instance_manager.dart | 501 +++----
.../lib/src/ad_listeners.dart | 72 +-
.../src/app_background_event_notifier.dart | 8 +-
.../google_mobile_ads/lib/src/mobile_ads.dart | 9 +-
.../native_template_font_style.dart | 2 +-
.../native_template_style.dart | 16 +-
.../src/nativetemplates/template_type.dart | 2 +-
.../lib/src/request_configuration.dart | 11 +-
.../lib/src/ump/consent_form.dart | 28 +-
.../lib/src/ump/consent_information.dart | 9 +-
.../lib/src/ump/consent_information_impl.dart | 14 +-
.../src/ump/consent_request_parameters.dart | 8 +-
.../lib/src/ump/user_messaging_channel.dart | 74 +-
.../lib/src/ump/user_messaging_codec.dart | 21 +-
packages/google_mobile_ads/pubspec.yaml | 14 +-
.../test/ad_containers_test.dart | 805 +++++++-----
.../test/admanager_banner_ad_test.dart | 126 +-
.../google_mobile_ads/test/app_open_test.dart | 148 ++-
.../test/banner_ad_test.dart | 126 +-
.../google_mobile_ads/test/fluid_ad_test.dart | 123 +-
.../test/mobile_ads_test.dart | 416 +++---
.../test/mobile_ads_test.mocks.dart | 1147 ++++++++---------
.../test/rewarded_interstitial_ad_test.dart | 317 +++--
.../google_mobile_ads/test/test_util.dart | 27 +-
.../test/ump/consent_form_impl_test.dart | 5 +-
.../ump/consent_form_impl_test.mocks.dart | 156 +--
.../test/ump/consent_form_test.dart | 38 +-
.../test/ump/consent_form_test.mocks.dart | 172 ++-
.../ump/consent_information_impl_test.dart | 41 +-
.../consent_information_impl_test.mocks.dart | 156 +--
.../test/ump/user_messaging_channel_test.dart | 281 ++--
.../test/ump/user_messaging_codec_test.dart | 11 +-
62 files changed, 3442 insertions(+), 2926 deletions(-)
diff --git a/packages/google_mobile_ads/CHANGELOG.md b/packages/google_mobile_ads/CHANGELOG.md
index 699008229..b23d4acde 100644
--- a/packages/google_mobile_ads/CHANGELOG.md
+++ b/packages/google_mobile_ads/CHANGELOG.md
@@ -1,3 +1,14 @@
+## 7.0.0
+* Added character limits expected for Native Ad Templates. Issues [1243](https://github.com/googleads/googleads-mobile-flutter/issues/1243) and [1332](https://github.com/googleads/googleads-mobile-flutter/issues/1332)
+* Fixed padding for Native Ads small template. [Issue 1357](https://github.com/googleads/googleads-mobile-flutter/issues/1357)
+* Updated to use Gradle plugin 9.2.1 [Issue 1361](https://github.com/googleads/googleads-mobile-flutter/issues/1361)
+* Updates dependencies. [Issue 1366](https://github.com/googleads/googleads-mobile-flutter/issues/1366)
+* Updates GMA [Android](https://developers.google.com/admob/android/rel-notes) dependency to 24.9.0
+* Updates GMA [iOS](https://developers.google.com/admob/ios/rel-notes) dependency to 12.14.0
+* Uses latest UMP SDK:
+ * [Android](https://developers.google.com/admob/android/privacy/release-notes) UMP SDK version 4.0.0.
+ * [iOS](https://developers.google.com/admob/ios/privacy/download#release_notes) UMP SDK version 3.1.0.
+
## 6.0.0
* Updates minimum Flutter SDK to 3.27.0
* Updates Dart SDK low bound to 3.6.0.
diff --git a/packages/google_mobile_ads/android/build.gradle b/packages/google_mobile_ads/android/build.gradle
index 948e368f3..009e9518e 100644
--- a/packages/google_mobile_ads/android/build.gradle
+++ b/packages/google_mobile_ads/android/build.gradle
@@ -1,14 +1,17 @@
group 'io.flutter.plugins.googlemobileads'
-version '6.0.0'
+version '7.0.0'
buildscript {
+ ext {
+ agp_version = '8.13.1'
+ }
repositories {
google()
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:8.3.2'
+ classpath "com.android.tools.build:gradle:$agp_version"
}
}
@@ -22,29 +25,29 @@ rootProject.allprojects {
apply plugin: 'com.android.library'
android {
- compileSdk 35
+ compileSdk 36
if (project.android.hasProperty('namespace')) {
namespace 'io.flutter.plugins.googlemobileads'
}
defaultConfig {
- minSdk 23
+ minSdk 24
}
lintOptions {
disable 'InvalidPackage'
}
dependencies {
- api 'com.google.android.gms:play-services-ads:24.1.0'
- implementation 'com.google.android.ump:user-messaging-platform:3.2.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
- implementation 'androidx.lifecycle:lifecycle-process:2.6.2'
- implementation 'com.google.errorprone:error_prone_annotations:2.16'
+ api 'com.google.android.gms:play-services-ads:24.9.0'
+ implementation 'com.google.android.ump:user-messaging-platform:4.0.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
+ implementation 'androidx.lifecycle:lifecycle-process:2.10.0'
+ implementation 'com.google.errorprone:error_prone_annotations:2.44.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.hamcrest:hamcrest:3.0'
- testImplementation 'org.mockito:mockito-core:5.15.2'
- testImplementation 'org.robolectric:robolectric:4.14.1'
- testImplementation 'androidx.test:core:1.5.0'
+ testImplementation 'org.mockito:mockito-core:5.20.0'
+ testImplementation 'org.robolectric:robolectric:4.16'
+ testImplementation 'androidx.test:core:1.7.0'
}
testOptions {
unitTests {
@@ -54,15 +57,11 @@ android {
}
afterEvaluate {
- def containsEmbeddingDependencies = false
- for (def configuration : configurations.all) {
- for (def dependency : configuration.dependencies) {
- if (dependency.group == 'io.flutter' &&
+ def containsEmbeddingDependencies = configurations.any { configuration ->
+ configuration.dependencies.any { dependency ->
+ dependency.group == 'io.flutter' &&
dependency.name.startsWith('flutter_embedding') &&
- dependency.isTransitive()) {
- containsEmbeddingDependencies = true
- break
- }
+ (dependency instanceof ModuleDependency && dependency.isTransitive())
}
}
if (!containsEmbeddingDependencies) {
diff --git a/packages/google_mobile_ads/android/gradle/wrapper/gradle-wrapper.properties b/packages/google_mobile_ads/android/gradle/wrapper/gradle-wrapper.properties
index 9c034ab11..c5856afbe 100644
--- a/packages/google_mobile_ads/android/gradle/wrapper/gradle-wrapper.properties
+++ b/packages/google_mobile_ads/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sat May 13 14:37:03 CEST 2023
+#Thu Dec 04 10:45:11 PST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/Constants.java b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/Constants.java
index cd12d7170..fc8c808aa 100644
--- a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/Constants.java
+++ b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/Constants.java
@@ -17,7 +17,7 @@
/** Constants used in the plugin. */
public class Constants {
/** Version request agent. Should be bumped alongside plugin versions. */
- public static final String REQUEST_AGENT_PREFIX_VERSIONED = "Flutter-GMA-6.0.0";
+ public static final String REQUEST_AGENT_PREFIX_VERSIONED = "Flutter-GMA-7.0.0";
/** Prefix for news template */
public static final String REQUEST_AGENT_NEWS_TEMPLATE_PREFIX = "News";
diff --git a/packages/google_mobile_ads/android/src/main/res/layout/gnt_medium_template_view.xml b/packages/google_mobile_ads/android/src/main/res/layout/gnt_medium_template_view.xml
index a9153d795..d4184b806 100644
--- a/packages/google_mobile_ads/android/src/main/res/layout/gnt_medium_template_view.xml
+++ b/packages/google_mobile_ads/android/src/main/res/layout/gnt_medium_template_view.xml
@@ -86,6 +86,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/gnt_no_size"
android:layout_weight="0.5"
+ android:maxLength="25"
android:gravity="left"
android:background="@android:color/transparent"
app:layout_constraintBottom_toTopOf="@+id/row_two"
@@ -197,17 +198,21 @@
android:paddingBottom="@dimen/gnt_default_margin"
android:paddingLeft="@dimen/gnt_default_margin"
android:id="@+id/body"
+ android:maxLength="90"
+ android:maxLines="2"
+ android:ellipsize="end"
app:layout_constraintBottom_toTopOf="@+id/cta"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/middle"
+ app:layout_constraintHeight_max="50dp"
android:paddingStart="@dimen/gnt_default_margin"
android:layout_marginBottom="@dimen/gnt_small_margin"
/>
diff --git a/packages/google_mobile_ads/android/src/main/res/layout/gnt_small_template_view.xml b/packages/google_mobile_ads/android/src/main/res/layout/gnt_small_template_view.xml
index 02db5fda2..189dbef42 100644
--- a/packages/google_mobile_ads/android/src/main/res/layout/gnt_small_template_view.xml
+++ b/packages/google_mobile_ads/android/src/main/res/layout/gnt_small_template_view.xml
@@ -18,10 +18,10 @@
arm64
MinimumOSVersion
- 11.0
+ 13.0
diff --git a/packages/google_mobile_ads/example/ios/Podfile b/packages/google_mobile_ads/example/ios/Podfile
index 03efaafd8..5dc3b65f7 100644
--- a/packages/google_mobile_ads/example/ios/Podfile
+++ b/packages/google_mobile_ads/example/ios/Podfile
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
-platform :ios, '12.0'
+platform :ios, '13.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
diff --git a/packages/google_mobile_ads/example/ios/Runner.xcodeproj/project.pbxproj b/packages/google_mobile_ads/example/ios/Runner.xcodeproj/project.pbxproj
index 3d588697c..9ec8e605a 100644
--- a/packages/google_mobile_ads/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/packages/google_mobile_ads/example/ios/Runner.xcodeproj/project.pbxproj
@@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
+ 887A5D54EBB22EE56FEA68C0 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D45D7A6903C5DAFE9FAFAD /* Pods_RunnerTests.framework */; };
8FC897F52411A9F100415930 /* NativeAdView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8FC897F42411A9F100415930 /* NativeAdView.xib */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
@@ -37,6 +38,7 @@
9E61AA6029BBE8FD00801A83 /* FLTNativeTemplateStyleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E61AA5B29BBE8FD00801A83 /* FLTNativeTemplateStyleTest.m */; };
9E61AA6129BBE8FD00801A83 /* FLTNativeTemplateFontStyleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E61AA5C29BBE8FD00801A83 /* FLTNativeTemplateFontStyleTest.m */; };
9E61AA6229BBE8FD00801A83 /* FLTNativeTemplateColorTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E61AA5D29BBE8FD00801A83 /* FLTNativeTemplateColorTest.m */; };
+ EBE2BC5BBFE6DB1E33F703F6 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE39CA478AEB75A8616A301A /* Pods_Runner.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -63,8 +65,12 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
+ 04096F79A89B65B77A1695FF /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
+ 0AA51DA50D3118092B5307E1 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; };
+ 0E1C520597602A0CDC46050E /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
+ 27D45D7A6903C5DAFE9FAFAD /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
44F3DED22B745BEE004D7117 /* FLTMediationExtras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FLTMediationExtras.h; path = ../../ios/Classes/FLTMediationExtras.h; sourceTree = ""; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
@@ -150,6 +156,8 @@
9EF4E6FE26392B230007E4FE /* FLTGoogleMobileAdsCollection_Internal.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = FLTGoogleMobileAdsCollection_Internal.m; path = ../../ios/Classes/FLTGoogleMobileAdsCollection_Internal.m; sourceTree = ""; };
9EF4E6FF26392B230007E4FE /* FLTMobileAds_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FLTMobileAds_Internal.h; path = ../../ios/Classes/FLTMobileAds_Internal.h; sourceTree = ""; };
9EFEAB4E29B0019F000A063B /* GoogleMobileAds.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = GoogleMobileAds.xcframework; path = "Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework/GoogleMobileAds.xcframework"; sourceTree = ""; };
+ A380EE5B67A6B0F501F9FBF1 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
+ FE39CA478AEB75A8616A301A /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -157,6 +165,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ EBE2BC5BBFE6DB1E33F703F6 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -164,6 +173,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 887A5D54EBB22EE56FEA68C0 /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -173,6 +183,10 @@
194BB02CA5CDABA098EA0B10 /* Pods */ = {
isa = PBXGroup;
children = (
+ 04096F79A89B65B77A1695FF /* Pods-Runner.debug.xcconfig */,
+ A380EE5B67A6B0F501F9FBF1 /* Pods-Runner.release.xcconfig */,
+ 0E1C520597602A0CDC46050E /* Pods-RunnerTests.debug.xcconfig */,
+ 0AA51DA50D3118092B5307E1 /* Pods-RunnerTests.release.xcconfig */,
);
path = Pods;
sourceTree = "";
@@ -183,6 +197,8 @@
9EFEAB4E29B0019F000A063B /* GoogleMobileAds.xcframework */,
9EB9FE57280F853D00DDBB4F /* UserMessagingPlatform.xcframework */,
9EA7213525BB6464008D57E3 /* GoogleMobileAds.xcframework */,
+ FE39CA478AEB75A8616A301A /* Pods_Runner.framework */,
+ 27D45D7A6903C5DAFE9FAFAD /* Pods_RunnerTests.framework */,
);
name = Frameworks;
sourceTree = "";
@@ -368,12 +384,15 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
+ 0EDD04BE717BEB4026757E35 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
+ D621B7120BAE5B88B39CB730 /* [CP] Embed Pods Frameworks */,
+ 352E2E45CC90E4DC15A87261 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@@ -388,9 +407,11 @@
isa = PBXNativeTarget;
buildConfigurationList = 9E61AA1E29BBE51900801A83 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
+ 1C462BC1BFB6789887F378CB /* [CP] Check Pods Manifest.lock */,
9E61AA1229BBE51900801A83 /* Sources */,
9E61AA1329BBE51900801A83 /* Frameworks */,
9E61AA1429BBE51900801A83 /* Resources */,
+ 01F28CB039EB603C0792037A /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@@ -464,6 +485,90 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
+ 01F28CB039EB603C0792037A /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-RunnerTests/Pods-RunnerTests-frameworks.sh",
+ "${BUILT_PRODUCTS_DIR}/OCMock/OCMock.framework",
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputPaths = (
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OCMock.framework",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RunnerTests/Pods-RunnerTests-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 0EDD04BE717BEB4026757E35 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 1C462BC1BFB6789887F378CB /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 352E2E45CC90E4DC15A87261 /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
+ "${PODS_CONFIGURATION_BUILD_DIR}/Google-Mobile-Ads-SDK/GoogleMobileAdsResources.bundle",
+ "${PODS_CONFIGURATION_BUILD_DIR}/GoogleUserMessagingPlatform/UserMessagingPlatformResources.bundle",
+ "${PODS_CONFIGURATION_BUILD_DIR}/google_mobile_ads/google_mobile_ads.bundle",
+ );
+ name = "[CP] Copy Pods Resources";
+ outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleMobileAdsResources.bundle",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/UserMessagingPlatformResources.bundle",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/google_mobile_ads.bundle",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@@ -471,6 +576,7 @@
files = (
);
inputPaths = (
+ "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
@@ -494,6 +600,24 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
};
+ D621B7120BAE5B88B39CB730 /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
+ "${BUILT_PRODUCTS_DIR}/webview_flutter_wkwebview/webview_flutter_wkwebview.framework",
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputPaths = (
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/webview_flutter_wkwebview.framework",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -616,7 +740,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 12.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -668,7 +792,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 12.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -689,7 +813,7 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 12.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -716,7 +840,7 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 12.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -732,6 +856,7 @@
};
9E61AA1C29BBE51900801A83 /* Debug */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = 0E1C520597602A0CDC46050E /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
@@ -758,6 +883,7 @@
};
9E61AA1D29BBE51900801A83 /* Release */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = 0AA51DA50D3118092B5307E1 /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
diff --git a/packages/google_mobile_ads/example/lib/anchored_adaptive_example.dart b/packages/google_mobile_ads/example/lib/anchored_adaptive_example.dart
index 8261a5c69..251ecc2e0 100644
--- a/packages/google_mobile_ads/example/lib/anchored_adaptive_example.dart
+++ b/packages/google_mobile_ads/example/lib/anchored_adaptive_example.dart
@@ -52,7 +52,8 @@ class _AnchoredAdaptiveExampleState extends State {
final AnchoredAdaptiveBannerAdSize? size =
await AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
- MediaQuery.of(context).size.width.truncate());
+ MediaQuery.of(context).size.width.truncate(),
+ );
if (size == null) {
print('Unable to get height of anchored banner.');
@@ -113,30 +114,29 @@ class _AnchoredAdaptiveExampleState extends State {
@override
Widget build(BuildContext context) => Scaffold(
- appBar: AppBar(
- title: Text('Anchored adaptive banner example'),
- ),
- body: Center(
- child: Stack(
- alignment: AlignmentDirectional.bottomCenter,
- children: [
- ListView.separated(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- itemBuilder: (context, index) {
- return Text(
- Constants.placeholderText,
- style: TextStyle(fontSize: 24),
- );
- },
- separatorBuilder: (context, index) {
- return Container(height: 40);
- },
- itemCount: 5),
- _getAdWidget(),
- ],
+ appBar: AppBar(title: Text('Anchored adaptive banner example')),
+ body: Center(
+ child: Stack(
+ alignment: AlignmentDirectional.bottomCenter,
+ children: [
+ ListView.separated(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ itemBuilder: (context, index) {
+ return Text(
+ Constants.placeholderText,
+ style: TextStyle(fontSize: 24),
+ );
+ },
+ separatorBuilder: (context, index) {
+ return Container(height: 40);
+ },
+ itemCount: 5,
),
- ),
- );
+ _getAdWidget(),
+ ],
+ ),
+ ),
+ );
@override
void dispose() {
diff --git a/packages/google_mobile_ads/example/lib/fluid_example.dart b/packages/google_mobile_ads/example/lib/fluid_example.dart
index ed2ff51ed..361ffee98 100644
--- a/packages/google_mobile_ads/example/lib/fluid_example.dart
+++ b/packages/google_mobile_ads/example/lib/fluid_example.dart
@@ -30,53 +30,48 @@ class _FluidExampleExampleState extends State {
@override
Widget build(BuildContext context) => Scaffold(
- appBar: AppBar(
- title: Text('Fluid example'),
- ),
- body: Center(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: ListView.separated(
- itemCount: 3,
- separatorBuilder: (BuildContext context, int index) {
- return Container(
- height: 40,
+ appBar: AppBar(title: Text('Fluid example')),
+ body: Center(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: ListView.separated(
+ itemCount: 3,
+ separatorBuilder: (BuildContext context, int index) {
+ return Container(height: 40);
+ },
+ itemBuilder: (BuildContext context, int index) {
+ if (index == 1) {
+ return Align(
+ alignment: Alignment.center,
+ child: FluidAdWidget(width: _width, ad: _fluidAd!),
);
- },
- itemBuilder: (BuildContext context, int index) {
- if (index == 1) {
- return Align(
- alignment: Alignment.center,
- child: FluidAdWidget(
- width: _width,
- ad: _fluidAd!,
- ),
- );
- } else if (index == 2) {
- return ElevatedButton(
- onPressed: () {
- double newWidth;
- if (_width == 200.0) {
- newWidth = 100.0;
- } else if (_width == 100.0) {
- newWidth = 150.0;
- } else {
- newWidth = 200.0;
- }
- setState(() {
- _width = newWidth;
- });
- },
- child: Text('Change size'));
- }
- return Text(
- Constants.placeholderText,
- style: TextStyle(fontSize: 24),
+ } else if (index == 2) {
+ return ElevatedButton(
+ onPressed: () {
+ double newWidth;
+ if (_width == 200.0) {
+ newWidth = 100.0;
+ } else if (_width == 100.0) {
+ newWidth = 150.0;
+ } else {
+ newWidth = 200.0;
+ }
+ setState(() {
+ _width = newWidth;
+ });
+ },
+ child: Text('Change size'),
);
- },
- ),
+ }
+ return Text(
+ Constants.placeholderText,
+ style: TextStyle(fontSize: 24),
+ );
+ },
),
- ));
+ ),
+ ),
+ );
@override
void didChangeDependencies() {
diff --git a/packages/google_mobile_ads/example/lib/inline_adaptive_example.dart b/packages/google_mobile_ads/example/lib/inline_adaptive_example.dart
index c6d4fc59e..0052508f9 100644
--- a/packages/google_mobile_ads/example/lib/inline_adaptive_example.dart
+++ b/packages/google_mobile_ads/example/lib/inline_adaptive_example.dart
@@ -54,12 +54,13 @@ class _InlineAdaptiveExampleState extends State {
// Get an inline adaptive size for the current orientation.
AdSize size = AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(
- _adWidth.truncate());
+ _adWidth.truncate(),
+ );
_inlineAdaptiveAd = AdManagerBannerAd(
adUnitId: Platform.isAndroid
? '/21775744923/example/banner'
- : '/6499/example/adaptive-banner',
+ : '/21775744923/example/adaptive-banner',
sizes: [size],
request: AdManagerAdRequest(),
listener: AdManagerBannerAdListener(
@@ -103,13 +104,12 @@ class _InlineAdaptiveExampleState extends State {
_isLoaded &&
_adSize != null) {
return Align(
- child: Container(
- width: _adWidth,
- height: _adSize!.height.toDouble(),
- child: AdWidget(
- ad: _inlineAdaptiveAd!,
+ child: Container(
+ width: _adWidth,
+ height: _adSize!.height.toDouble(),
+ child: AdWidget(ad: _inlineAdaptiveAd!),
),
- ));
+ );
}
// Reload the ad if the orientation changes.
if (_currentOrientation != orientation) {
@@ -123,31 +123,28 @@ class _InlineAdaptiveExampleState extends State {
@override
Widget build(BuildContext context) => Scaffold(
- appBar: AppBar(
- title: Text('Inline adaptive banner example'),
- ),
- body: Center(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: _insets),
- child: ListView.separated(
- itemCount: 3,
- separatorBuilder: (BuildContext context, int index) {
- return Container(
- height: 40,
- );
- },
- itemBuilder: (BuildContext context, int index) {
- if (index == 1) {
- return _getAdWidget();
- }
- return Text(
- Constants.placeholderText,
- style: TextStyle(fontSize: 24),
- );
- },
- ),
+ appBar: AppBar(title: Text('Inline adaptive banner example')),
+ body: Center(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: _insets),
+ child: ListView.separated(
+ itemCount: 3,
+ separatorBuilder: (BuildContext context, int index) {
+ return Container(height: 40);
+ },
+ itemBuilder: (BuildContext context, int index) {
+ if (index == 1) {
+ return _getAdWidget();
+ }
+ return Text(
+ Constants.placeholderText,
+ style: TextStyle(fontSize: 24),
+ );
+ },
),
- ));
+ ),
+ ),
+ );
@override
void dispose() {
diff --git a/packages/google_mobile_ads/example/lib/main.dart b/packages/google_mobile_ads/example/lib/main.dart
index bdb7130cf..8ee75cb54 100644
--- a/packages/google_mobile_ads/example/lib/main.dart
+++ b/packages/google_mobile_ads/example/lib/main.dart
@@ -76,7 +76,8 @@ class _MyAppState extends State {
void initState() {
super.initState();
MobileAds.instance.updateRequestConfiguration(
- RequestConfiguration(testDeviceIds: [testDevice]));
+ RequestConfiguration(testDeviceIds: [testDevice]),
+ );
_createInterstitialAd();
_createRewardedAd();
_createRewardedInterstitialAd();
@@ -84,26 +85,27 @@ class _MyAppState extends State {
void _createInterstitialAd() {
InterstitialAd.load(
- adUnitId: Platform.isAndroid
- ? 'ca-app-pub-3940256099942544/1033173712'
- : 'ca-app-pub-3940256099942544/4411468910',
- request: request,
- adLoadCallback: InterstitialAdLoadCallback(
- onAdLoaded: (InterstitialAd ad) {
- print('$ad loaded');
- _interstitialAd = ad;
- _numInterstitialLoadAttempts = 0;
- _interstitialAd!.setImmersiveMode(true);
- },
- onAdFailedToLoad: (LoadAdError error) {
- print('InterstitialAd failed to load: $error.');
- _numInterstitialLoadAttempts += 1;
- _interstitialAd = null;
- if (_numInterstitialLoadAttempts < maxFailedLoadAttempts) {
- _createInterstitialAd();
- }
- },
- ));
+ adUnitId: Platform.isAndroid
+ ? 'ca-app-pub-3940256099942544/1033173712'
+ : 'ca-app-pub-3940256099942544/4411468910',
+ request: request,
+ adLoadCallback: InterstitialAdLoadCallback(
+ onAdLoaded: (InterstitialAd ad) {
+ print('$ad loaded');
+ _interstitialAd = ad;
+ _numInterstitialLoadAttempts = 0;
+ _interstitialAd!.setImmersiveMode(true);
+ },
+ onAdFailedToLoad: (LoadAdError error) {
+ print('InterstitialAd failed to load: $error.');
+ _numInterstitialLoadAttempts += 1;
+ _interstitialAd = null;
+ if (_numInterstitialLoadAttempts < maxFailedLoadAttempts) {
+ _createInterstitialAd();
+ }
+ },
+ ),
+ );
}
void _showInterstitialAd() {
@@ -131,25 +133,26 @@ class _MyAppState extends State {
void _createRewardedAd() {
RewardedAd.load(
- adUnitId: Platform.isAndroid
- ? 'ca-app-pub-3940256099942544/5224354917'
- : 'ca-app-pub-3940256099942544/1712485313',
- request: request,
- rewardedAdLoadCallback: RewardedAdLoadCallback(
- onAdLoaded: (RewardedAd ad) {
- print('$ad loaded.');
- _rewardedAd = ad;
- _numRewardedLoadAttempts = 0;
- },
- onAdFailedToLoad: (LoadAdError error) {
- print('RewardedAd failed to load: $error');
- _rewardedAd = null;
- _numRewardedLoadAttempts += 1;
- if (_numRewardedLoadAttempts < maxFailedLoadAttempts) {
- _createRewardedAd();
- }
- },
- ));
+ adUnitId: Platform.isAndroid
+ ? 'ca-app-pub-3940256099942544/5224354917'
+ : 'ca-app-pub-3940256099942544/1712485313',
+ request: request,
+ rewardedAdLoadCallback: RewardedAdLoadCallback(
+ onAdLoaded: (RewardedAd ad) {
+ print('$ad loaded.');
+ _rewardedAd = ad;
+ _numRewardedLoadAttempts = 0;
+ },
+ onAdFailedToLoad: (LoadAdError error) {
+ print('RewardedAd failed to load: $error');
+ _rewardedAd = null;
+ _numRewardedLoadAttempts += 1;
+ if (_numRewardedLoadAttempts < maxFailedLoadAttempts) {
+ _createRewardedAd();
+ }
+ },
+ ),
+ );
}
void _showRewardedAd() {
@@ -174,33 +177,35 @@ class _MyAppState extends State {
_rewardedAd!.setImmersiveMode(true);
_rewardedAd!.show(
- onUserEarnedReward: (AdWithoutView ad, RewardItem reward) {
- print('$ad with reward $RewardItem(${reward.amount}, ${reward.type})');
- });
+ onUserEarnedReward: (AdWithoutView ad, RewardItem reward) {
+ print('$ad with reward $RewardItem(${reward.amount}, ${reward.type})');
+ },
+ );
_rewardedAd = null;
}
void _createRewardedInterstitialAd() {
RewardedInterstitialAd.load(
- adUnitId: Platform.isAndroid
- ? 'ca-app-pub-3940256099942544/5354046379'
- : 'ca-app-pub-3940256099942544/6978759866',
- request: request,
- rewardedInterstitialAdLoadCallback: RewardedInterstitialAdLoadCallback(
- onAdLoaded: (RewardedInterstitialAd ad) {
- print('$ad loaded.');
- _rewardedInterstitialAd = ad;
- _numRewardedInterstitialLoadAttempts = 0;
- },
- onAdFailedToLoad: (LoadAdError error) {
- print('RewardedInterstitialAd failed to load: $error');
- _rewardedInterstitialAd = null;
- _numRewardedInterstitialLoadAttempts += 1;
- if (_numRewardedInterstitialLoadAttempts < maxFailedLoadAttempts) {
- _createRewardedInterstitialAd();
- }
- },
- ));
+ adUnitId: Platform.isAndroid
+ ? 'ca-app-pub-3940256099942544/5354046379'
+ : 'ca-app-pub-3940256099942544/6978759866',
+ request: request,
+ rewardedInterstitialAdLoadCallback: RewardedInterstitialAdLoadCallback(
+ onAdLoaded: (RewardedInterstitialAd ad) {
+ print('$ad loaded.');
+ _rewardedInterstitialAd = ad;
+ _numRewardedInterstitialLoadAttempts = 0;
+ },
+ onAdFailedToLoad: (LoadAdError error) {
+ print('RewardedInterstitialAd failed to load: $error');
+ _rewardedInterstitialAd = null;
+ _numRewardedInterstitialLoadAttempts += 1;
+ if (_numRewardedInterstitialLoadAttempts < maxFailedLoadAttempts) {
+ _createRewardedInterstitialAd();
+ }
+ },
+ ),
+ );
}
void _showRewardedInterstitialAd() {
@@ -210,26 +215,27 @@ class _MyAppState extends State {
}
_rewardedInterstitialAd!.fullScreenContentCallback =
FullScreenContentCallback(
- onAdShowedFullScreenContent: (RewardedInterstitialAd ad) =>
- print('$ad onAdShowedFullScreenContent.'),
- onAdDismissedFullScreenContent: (RewardedInterstitialAd ad) {
- print('$ad onAdDismissedFullScreenContent.');
- ad.dispose();
- _createRewardedInterstitialAd();
- },
- onAdFailedToShowFullScreenContent:
- (RewardedInterstitialAd ad, AdError error) {
- print('$ad onAdFailedToShowFullScreenContent: $error');
- ad.dispose();
- _createRewardedInterstitialAd();
- },
- );
+ onAdShowedFullScreenContent: (RewardedInterstitialAd ad) =>
+ print('$ad onAdShowedFullScreenContent.'),
+ onAdDismissedFullScreenContent: (RewardedInterstitialAd ad) {
+ print('$ad onAdDismissedFullScreenContent.');
+ ad.dispose();
+ _createRewardedInterstitialAd();
+ },
+ onAdFailedToShowFullScreenContent:
+ (RewardedInterstitialAd ad, AdError error) {
+ print('$ad onAdFailedToShowFullScreenContent: $error');
+ ad.dispose();
+ _createRewardedInterstitialAd();
+ },
+ );
_rewardedInterstitialAd!.setImmersiveMode(true);
_rewardedInterstitialAd!.show(
- onUserEarnedReward: (AdWithoutView ad, RewardItem reward) {
- print('$ad with reward $RewardItem(${reward.amount}, ${reward.type})');
- });
+ onUserEarnedReward: (AdWithoutView ad, RewardItem reward) {
+ print('$ad with reward $RewardItem(${reward.amount}, ${reward.type})');
+ },
+ );
_rewardedInterstitialAd = null;
}
@@ -244,124 +250,139 @@ class _MyAppState extends State {
@override
Widget build(BuildContext context) {
return MaterialApp(
- home: Builder(builder: (BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: const Text('AdMob Plugin example app'),
- actions: [
- PopupMenuButton(
- onSelected: (String result) {
- switch (result) {
- case interstitialButtonText:
- _showInterstitialAd();
- break;
- case rewardedButtonText:
- _showRewardedAd();
- break;
- case rewardedInterstitialButtonText:
- _showRewardedInterstitialAd();
- break;
- case fluidButtonText:
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => FluidExample()),
- );
- break;
- case inlineAdaptiveButtonText:
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => InlineAdaptiveExample()),
- );
- break;
- case mulipleInlineAdaptiveWithRecycleButtonText:
- Navigator.push(
- context,
- MaterialPageRoute(
+ home: Builder(
+ builder: (BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: const Text('AdMob Plugin example app'),
+ actions: [
+ PopupMenuButton(
+ onSelected: (String result) {
+ switch (result) {
+ case interstitialButtonText:
+ _showInterstitialAd();
+ break;
+ case rewardedButtonText:
+ _showRewardedAd();
+ break;
+ case rewardedInterstitialButtonText:
+ _showRewardedInterstitialAd();
+ break;
+ case fluidButtonText:
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => FluidExample(),
+ ),
+ );
+ break;
+ case inlineAdaptiveButtonText:
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => InlineAdaptiveExample(),
+ ),
+ );
+ break;
+ case mulipleInlineAdaptiveWithRecycleButtonText:
+ Navigator.push(
+ context,
+ MaterialPageRoute(
builder: (context) =>
- MultiInlineAdaptiveWithRecycleExample()),
- );
- break;
- case anchoredAdaptiveButtonText:
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => AnchoredAdaptiveExample()),
- );
- break;
- case nativeTemplateButtonText:
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => NativeTemplateExample()),
- );
- break;
- case webviewExampleButtonText:
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => WebViewExample()),
- );
- break;
- case adInspectorButtonText:
- MobileAds.instance.openAdInspector((error) => log(
- 'Ad Inspector ' +
- (error == null
- ? 'opened.'
- : 'error: ' + (error.message ?? ''))));
- break;
- default:
- throw AssertionError('unexpected button: $result');
- }
- },
- itemBuilder: (BuildContext context) => >[
- PopupMenuItem(
- value: interstitialButtonText,
- child: Text(interstitialButtonText),
- ),
- PopupMenuItem(
- value: rewardedButtonText,
- child: Text(rewardedButtonText),
- ),
- PopupMenuItem(
- value: rewardedInterstitialButtonText,
- child: Text(rewardedInterstitialButtonText),
- ),
- PopupMenuItem(
- value: fluidButtonText,
- child: Text(fluidButtonText),
- ),
- PopupMenuItem(
- value: inlineAdaptiveButtonText,
- child: Text(inlineAdaptiveButtonText),
- ),
- PopupMenuItem(
- value: mulipleInlineAdaptiveWithRecycleButtonText,
- child: Text(mulipleInlineAdaptiveWithRecycleButtonText),
- ),
- PopupMenuItem(
- value: anchoredAdaptiveButtonText,
- child: Text(anchoredAdaptiveButtonText),
- ),
- PopupMenuItem(
- value: nativeTemplateButtonText,
- child: Text(nativeTemplateButtonText),
- ),
- PopupMenuItem(
- value: webviewExampleButtonText,
- child: Text(webviewExampleButtonText),
- ),
- PopupMenuItem(
- value: adInspectorButtonText,
- child: Text(adInspectorButtonText),
- ),
- ],
- ),
- ],
- ),
- body: SafeArea(child: ReusableInlineExample()),
- );
- }),
+ MultiInlineAdaptiveWithRecycleExample(),
+ ),
+ );
+ break;
+ case anchoredAdaptiveButtonText:
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => AnchoredAdaptiveExample(),
+ ),
+ );
+ break;
+ case nativeTemplateButtonText:
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => NativeTemplateExample(),
+ ),
+ );
+ break;
+ case webviewExampleButtonText:
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => WebViewExample(),
+ ),
+ );
+ break;
+ case adInspectorButtonText:
+ MobileAds.instance.openAdInspector(
+ (error) => log(
+ 'Ad Inspector ' +
+ (error == null
+ ? 'opened.'
+ : 'error: ' + (error.message ?? '')),
+ ),
+ );
+ break;
+ default:
+ throw AssertionError('unexpected button: $result');
+ }
+ },
+ itemBuilder: (BuildContext context) =>
+ >[
+ PopupMenuItem(
+ value: interstitialButtonText,
+ child: Text(interstitialButtonText),
+ ),
+ PopupMenuItem(
+ value: rewardedButtonText,
+ child: Text(rewardedButtonText),
+ ),
+ PopupMenuItem(
+ value: rewardedInterstitialButtonText,
+ child: Text(rewardedInterstitialButtonText),
+ ),
+ PopupMenuItem(
+ value: fluidButtonText,
+ child: Text(fluidButtonText),
+ ),
+ PopupMenuItem(
+ value: inlineAdaptiveButtonText,
+ child: Text(inlineAdaptiveButtonText),
+ ),
+ PopupMenuItem(
+ value: mulipleInlineAdaptiveWithRecycleButtonText,
+ child: Text(
+ mulipleInlineAdaptiveWithRecycleButtonText,
+ ),
+ ),
+ PopupMenuItem(
+ value: anchoredAdaptiveButtonText,
+ child: Text(anchoredAdaptiveButtonText),
+ ),
+ PopupMenuItem(
+ value: nativeTemplateButtonText,
+ child: Text(nativeTemplateButtonText),
+ ),
+ PopupMenuItem(
+ value: webviewExampleButtonText,
+ child: Text(webviewExampleButtonText),
+ ),
+ PopupMenuItem(
+ value: adInspectorButtonText,
+ child: Text(adInspectorButtonText),
+ ),
+ ],
+ ),
+ ],
+ ),
+ body: SafeArea(child: ReusableInlineExample()),
+ );
+ },
+ ),
);
}
}
diff --git a/packages/google_mobile_ads/example/lib/multi_adaptive_inline_with_recycle_example.dart b/packages/google_mobile_ads/example/lib/multi_adaptive_inline_with_recycle_example.dart
index 40c942a12..f1c310c27 100644
--- a/packages/google_mobile_ads/example/lib/multi_adaptive_inline_with_recycle_example.dart
+++ b/packages/google_mobile_ads/example/lib/multi_adaptive_inline_with_recycle_example.dart
@@ -100,37 +100,41 @@ class _MultiInlineAdaptiveWithRecycleExampleState
return Scaffold(
appBar: AppBar(title: Text('Adaptive Size, Recycle')),
body: ListView.builder(
- // Arbitrary example of 100 items in the list.
- itemCount: 100,
- itemBuilder: (BuildContext context, int index) {
- if (index % _adInterval == 0) {
- int bannerPosition = index ~/ _adInterval;
- BannerAd bannerAd = _getRecycledBannerAd(bannerPosition);
- final AdSize? adSize = _bannerSizes[bannerAd];
- if (adSize == null) {
- // Null adSize means the banner's content is not fetched yet.
- return SizedBox.shrink();
- }
- // Now this banner is loaded with ad content and corresponding ad size.
- return SizedBox(
- width: adSize.width.toDouble(),
- height: adSize.height.toDouble(),
- child: AdWidget(ad: bannerAd));
+ // Arbitrary example of 100 items in the list.
+ itemCount: 100,
+ itemBuilder: (BuildContext context, int index) {
+ if (index % _adInterval == 0) {
+ int bannerPosition = index ~/ _adInterval;
+ BannerAd bannerAd = _getRecycledBannerAd(bannerPosition);
+ final AdSize? adSize = _bannerSizes[bannerAd];
+ if (adSize == null) {
+ // Null adSize means the banner's content is not fetched yet.
+ return SizedBox.shrink();
}
+ // Now this banner is loaded with ad content and corresponding ad size.
+ return SizedBox(
+ width: adSize.width.toDouble(),
+ height: adSize.height.toDouble(),
+ child: AdWidget(ad: bannerAd),
+ );
+ }
- // Show your regular non-ad content.
- return Container(
- decoration: BoxDecoration(
- border: Border.all(
- color: Colors.blue,
- width: 1.0,
- style: BorderStyle.solid,
- ),
+ // Show your regular non-ad content.
+ return Container(
+ decoration: BoxDecoration(
+ border: Border.all(
+ color: Colors.blue,
+ width: 1.0,
+ style: BorderStyle.solid,
),
- child: SizedBox(
- height: 100, child: ColoredBox(color: Colors.yellow)),
- );
- }),
+ ),
+ child: SizedBox(
+ height: 100,
+ child: ColoredBox(color: Colors.yellow),
+ ),
+ );
+ },
+ ),
);
}
diff --git a/packages/google_mobile_ads/example/lib/native_template_example.dart b/packages/google_mobile_ads/example/lib/native_template_example.dart
index ae2ce51df..415db8ed0 100644
--- a/packages/google_mobile_ads/example/lib/native_template_example.dart
+++ b/packages/google_mobile_ads/example/lib/native_template_example.dart
@@ -31,41 +31,39 @@ class _NativeTemplateExampleExampleState extends State {
@override
Widget build(BuildContext context) => Scaffold(
- appBar: AppBar(
- title: Text('Native templates example'),
- ),
- body: Center(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: ListView.separated(
- itemCount: 10,
- separatorBuilder: (BuildContext context, int index) {
- return Container(
- height: 40,
- );
- },
- itemBuilder: (BuildContext context, int index) {
- if (index == 5 && _nativeAd != null && _nativeAdIsLoaded) {
- return Align(
- alignment: Alignment.center,
- child: ConstrainedBox(
- constraints: const BoxConstraints(
- minWidth: 300,
- minHeight: 350,
- maxHeight: 400,
- maxWidth: 450,
- ),
- child: AdWidget(ad: _nativeAd!),
- ));
- }
- return Text(
- Constants.placeholderText,
- style: TextStyle(fontSize: 24),
+ appBar: AppBar(title: Text('Native templates example')),
+ body: Center(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: ListView.separated(
+ itemCount: 10,
+ separatorBuilder: (BuildContext context, int index) {
+ return Container(height: 40);
+ },
+ itemBuilder: (BuildContext context, int index) {
+ if (index == 5 && _nativeAd != null && _nativeAdIsLoaded) {
+ return Align(
+ alignment: Alignment.center,
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(
+ minWidth: 300,
+ minHeight: 350,
+ maxHeight: 400,
+ maxWidth: 450,
+ ),
+ child: AdWidget(ad: _nativeAd!),
+ ),
);
- },
- ),
+ }
+ return Text(
+ Constants.placeholderText,
+ style: TextStyle(fontSize: 24),
+ );
+ },
),
- ));
+ ),
+ ),
+ );
@override
void didChangeDependencies() {
@@ -91,9 +89,7 @@ class _NativeTemplateExampleExampleState extends State {
nativeTemplateStyle: NativeTemplateStyle(
templateType: TemplateType.medium,
mainBackgroundColor: Colors.white12,
- callToActionTextStyle: NativeTemplateTextStyle(
- size: 16.0,
- ),
+ callToActionTextStyle: NativeTemplateTextStyle(size: 16.0),
primaryTextStyle: NativeTemplateTextStyle(
textColor: Colors.black38,
backgroundColor: Colors.white70,
diff --git a/packages/google_mobile_ads/example/lib/reusable_inline_example.dart b/packages/google_mobile_ads/example/lib/reusable_inline_example.dart
index cec91c280..187111618 100644
--- a/packages/google_mobile_ads/example/lib/reusable_inline_example.dart
+++ b/packages/google_mobile_ads/example/lib/reusable_inline_example.dart
@@ -38,74 +38,77 @@ class _ReusableInlineExampleState extends State {
@override
Widget build(BuildContext context) => Center(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: ListView.separated(
- itemCount: 20,
- separatorBuilder: (BuildContext context, int index) {
- return Container(
- height: 40,
- );
- },
- itemBuilder: (BuildContext context, int index) {
- final BannerAd? bannerAd = _bannerAd;
- if (index == 5 && _bannerAdIsLoaded && bannerAd != null) {
- return Container(
- height: bannerAd.size.height.toDouble(),
- width: bannerAd.size.width.toDouble(),
- child: AdWidget(ad: bannerAd));
- }
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: ListView.separated(
+ itemCount: 20,
+ separatorBuilder: (BuildContext context, int index) {
+ return Container(height: 40);
+ },
+ itemBuilder: (BuildContext context, int index) {
+ final BannerAd? bannerAd = _bannerAd;
+ if (index == 5 && _bannerAdIsLoaded && bannerAd != null) {
+ return Container(
+ height: bannerAd.size.height.toDouble(),
+ width: bannerAd.size.width.toDouble(),
+ child: AdWidget(ad: bannerAd),
+ );
+ }
- final AdManagerBannerAd? adManagerBannerAd = _adManagerBannerAd;
- if (index == 10 &&
- _adManagerBannerAdIsLoaded &&
- adManagerBannerAd != null) {
- return Container(
- height: adManagerBannerAd.sizes[0].height.toDouble(),
- width: adManagerBannerAd.sizes[0].width.toDouble(),
- child: AdWidget(ad: _adManagerBannerAd!));
- }
+ final AdManagerBannerAd? adManagerBannerAd = _adManagerBannerAd;
+ if (index == 10 &&
+ _adManagerBannerAdIsLoaded &&
+ adManagerBannerAd != null) {
+ return Container(
+ height: adManagerBannerAd.sizes[0].height.toDouble(),
+ width: adManagerBannerAd.sizes[0].width.toDouble(),
+ child: AdWidget(ad: _adManagerBannerAd!),
+ );
+ }
- final NativeAd? nativeAd = _nativeAd;
- if (index == 15 && _nativeAdIsLoaded && nativeAd != null) {
- return Container(
- width: 250, height: 350, child: AdWidget(ad: nativeAd));
- }
+ final NativeAd? nativeAd = _nativeAd;
+ if (index == 15 && _nativeAdIsLoaded && nativeAd != null) {
+ return Container(
+ width: 250,
+ height: 350,
+ child: AdWidget(ad: nativeAd),
+ );
+ }
- return Text(
- Constants.placeholderText,
- style: TextStyle(fontSize: 24),
- );
- },
- ),
- ),
- );
+ return Text(
+ Constants.placeholderText,
+ style: TextStyle(fontSize: 24),
+ );
+ },
+ ),
+ ),
+ );
@override
void didChangeDependencies() {
super.didChangeDependencies();
// Create the ad objects and load ads.
_bannerAd = BannerAd(
- size: AdSize.banner,
- adUnitId: Platform.isAndroid
- ? 'ca-app-pub-3940256099942544/6300978111'
- : 'ca-app-pub-3940256099942544/2934735716',
- listener: BannerAdListener(
- onAdLoaded: (Ad ad) {
- print('$BannerAd loaded.');
- setState(() {
- _bannerAdIsLoaded = true;
- });
- },
- onAdFailedToLoad: (Ad ad, LoadAdError error) {
- print('$BannerAd failedToLoad: $error');
- ad.dispose();
- },
- onAdOpened: (Ad ad) => print('$BannerAd onAdOpened.'),
- onAdClosed: (Ad ad) => print('$BannerAd onAdClosed.'),
- ),
- request: AdRequest())
- ..load();
+ size: AdSize.banner,
+ adUnitId: Platform.isAndroid
+ ? 'ca-app-pub-3940256099942544/6300978111'
+ : 'ca-app-pub-3940256099942544/2934735716',
+ listener: BannerAdListener(
+ onAdLoaded: (Ad ad) {
+ print('$BannerAd loaded.');
+ setState(() {
+ _bannerAdIsLoaded = true;
+ });
+ },
+ onAdFailedToLoad: (Ad ad, LoadAdError error) {
+ print('$BannerAd failedToLoad: $error');
+ ad.dispose();
+ },
+ onAdOpened: (Ad ad) => print('$BannerAd onAdOpened.'),
+ onAdClosed: (Ad ad) => print('$BannerAd onAdClosed.'),
+ ),
+ request: AdRequest(),
+ )..load();
_nativeAd = NativeAd(
adUnitId: Platform.isAndroid
diff --git a/packages/google_mobile_ads/example/lib/snippets/banner_ad_snippets.dart b/packages/google_mobile_ads/example/lib/snippets/banner_ad_snippets.dart
index 4383292db..b2f9370ca 100644
--- a/packages/google_mobile_ads/example/lib/snippets/banner_ad_snippets.dart
+++ b/packages/google_mobile_ads/example/lib/snippets/banner_ad_snippets.dart
@@ -47,25 +47,27 @@ class _BannerAdSnippets extends State<_BannerAdWidget> {
return;
}
- unawaited(BannerAd(
- adUnitId: _adUnitId,
- request: const AdManagerAdRequest(),
- size: size,
- listener: BannerAdListener(
- onAdLoaded: (ad) {
- // Called when an ad is successfully received.
- debugPrint('Ad was loaded.');
- setState(() {
- _bannerAd = ad as BannerAd;
- });
- },
- onAdFailedToLoad: (ad, err) {
- // Called when an ad request failed.
- debugPrint('Ad failed to load with error: $err');
- ad.dispose();
- },
- ),
- ).load());
+ unawaited(
+ BannerAd(
+ adUnitId: _adUnitId,
+ request: const AdManagerAdRequest(),
+ size: size,
+ listener: BannerAdListener(
+ onAdLoaded: (ad) {
+ // Called when an ad is successfully received.
+ debugPrint('Ad was loaded.');
+ setState(() {
+ _bannerAd = ad as BannerAd;
+ });
+ },
+ onAdFailedToLoad: (ad, err) {
+ // Called when an ad request failed.
+ debugPrint('Ad failed to load with error: $err');
+ ad.dispose();
+ },
+ ),
+ ).load(),
+ );
}
// [END load_ad_ad_manager]
diff --git a/packages/google_mobile_ads/example/lib/snippets/interstitial_ad_snippets.dart b/packages/google_mobile_ads/example/lib/snippets/interstitial_ad_snippets.dart
index 638cc1719..10d49c891 100644
--- a/packages/google_mobile_ads/example/lib/snippets/interstitial_ad_snippets.dart
+++ b/packages/google_mobile_ads/example/lib/snippets/interstitial_ad_snippets.dart
@@ -82,9 +82,9 @@ class _InterstitialAdSnippets {
// [END ad_events]
}
-// ===================================================================
-// Ad Manager snippets
-// ===================================================================
+ // ===================================================================
+ // Ad Manager snippets
+ // ===================================================================
void _loadAdManagerInterstitialAd() {
// [START load_ad_ad_manager]
diff --git a/packages/google_mobile_ads/example/lib/snippets/rewarded_ad_snippets.dart b/packages/google_mobile_ads/example/lib/snippets/rewarded_ad_snippets.dart
index 32914b198..82b152ed1 100644
--- a/packages/google_mobile_ads/example/lib/snippets/rewarded_ad_snippets.dart
+++ b/packages/google_mobile_ads/example/lib/snippets/rewarded_ad_snippets.dart
@@ -91,7 +91,8 @@ class _RewardedAdSnippets {
onAdLoaded: (ad) {
ServerSideVerificationOptions _options =
ServerSideVerificationOptions(
- customData: 'SAMPLE_CUSTOM_DATA_STRING');
+ customData: 'SAMPLE_CUSTOM_DATA_STRING',
+ );
ad.setServerSideOptions(_options);
_rewardedAd = ad;
},
@@ -101,9 +102,9 @@ class _RewardedAdSnippets {
// [END validate_server_side_verification]
}
-// ===================================================================
-// Ad Manager snippets
-// ===================================================================
+ // ===================================================================
+ // Ad Manager snippets
+ // ===================================================================
void _loadAdManagerRewardedAd() {
// [START load_ad_ad_manager]
@@ -138,7 +139,8 @@ class _RewardedAdSnippets {
onAdLoaded: (ad) {
ServerSideVerificationOptions _options =
ServerSideVerificationOptions(
- customData: 'SAMPLE_CUSTOM_DATA_STRING');
+ customData: 'SAMPLE_CUSTOM_DATA_STRING',
+ );
ad.setServerSideOptions(_options);
_rewardedAd = ad;
},
diff --git a/packages/google_mobile_ads/example/lib/snippets/rewarded_interstitial_ad_snippets.dart b/packages/google_mobile_ads/example/lib/snippets/rewarded_interstitial_ad_snippets.dart
index 19073f482..ff932b61b 100644
--- a/packages/google_mobile_ads/example/lib/snippets/rewarded_interstitial_ad_snippets.dart
+++ b/packages/google_mobile_ads/example/lib/snippets/rewarded_interstitial_ad_snippets.dart
@@ -92,7 +92,8 @@ class _RewardedInterstitialAdSnippets {
onAdLoaded: (ad) {
ServerSideVerificationOptions _options =
ServerSideVerificationOptions(
- customData: 'SAMPLE_CUSTOM_DATA_STRING');
+ customData: 'SAMPLE_CUSTOM_DATA_STRING',
+ );
ad.setServerSideOptions(_options);
_rewardedInterstitialAd = ad;
},
@@ -102,9 +103,9 @@ class _RewardedInterstitialAdSnippets {
// [END validate_server_side_verification]
}
-// ===================================================================
-// Ad Manager snippets
-// ===================================================================
+ // ===================================================================
+ // Ad Manager snippets
+ // ===================================================================
void _loadAdManagerRewardedInterstitialAd() {
// [START load_ad_ad_manager]
@@ -139,7 +140,8 @@ class _RewardedInterstitialAdSnippets {
onAdLoaded: (ad) {
ServerSideVerificationOptions _options =
ServerSideVerificationOptions(
- customData: 'SAMPLE_CUSTOM_DATA_STRING');
+ customData: 'SAMPLE_CUSTOM_DATA_STRING',
+ );
ad.setServerSideOptions(_options);
_rewardedInterstitialAd = ad;
},
diff --git a/packages/google_mobile_ads/example/lib/webview_example.dart b/packages/google_mobile_ads/example/lib/webview_example.dart
index fb003374f..e0dc505f2 100644
--- a/packages/google_mobile_ads/example/lib/webview_example.dart
+++ b/packages/google_mobile_ads/example/lib/webview_example.dart
@@ -62,12 +62,16 @@ class _WebViewExampleState extends State {
);
if (controller.platform is AndroidWebViewController) {
AndroidWebViewCookieManager cookieManager = AndroidWebViewCookieManager(
- PlatformWebViewCookieManagerCreationParams());
+ PlatformWebViewCookieManagerCreationParams(),
+ );
await cookieManager.setAcceptThirdPartyCookies(
- controller.platform as AndroidWebViewController, true);
+ controller.platform as AndroidWebViewController,
+ true,
+ );
}
await MobileAds.instance.registerWebView(controller);
- await controller
- .loadRequest(Uri.parse('https://webview-api-for-ads-test.glitch.me/'));
+ await controller.loadRequest(
+ Uri.parse('https://webview-api-for-ads-test.glitch.me/'),
+ );
}
}
diff --git a/packages/google_mobile_ads/example/pubspec.yaml b/packages/google_mobile_ads/example/pubspec.yaml
index 0c3fcf18e..aa0ac8594 100644
--- a/packages/google_mobile_ads/example/pubspec.yaml
+++ b/packages/google_mobile_ads/example/pubspec.yaml
@@ -22,7 +22,7 @@ dependencies:
sdk: flutter
google_mobile_ads:
path: ../
- webview_flutter_android: ^4.3.1
+ webview_flutter_android: ^4.10.9
webview_flutter: ^4.10.0
dev_dependencies:
@@ -34,4 +34,4 @@ flutter:
uses-material-design: true
environment:
- sdk: ">=3.6.0 <4.0.0"
+ sdk: ">=3.9.0 <4.0.0"
diff --git a/packages/google_mobile_ads/ios/Classes/FLTConstants.h b/packages/google_mobile_ads/ios/Classes/FLTConstants.h
index c72a0c98d..de436414d 100644
--- a/packages/google_mobile_ads/ios/Classes/FLTConstants.h
+++ b/packages/google_mobile_ads/ios/Classes/FLTConstants.h
@@ -13,4 +13,4 @@
// limitations under the License.
/** Versioned request agent string. */
-#define FLT_REQUEST_AGENT_VERSIONED @"Flutter-GMA-6.0.0"
+#define FLT_REQUEST_AGENT_VERSIONED @"Flutter-GMA-7.0.0"
diff --git a/packages/google_mobile_ads/ios/google_mobile_ads.podspec b/packages/google_mobile_ads/ios/google_mobile_ads.podspec
index cb6ecc020..e503293f3 100644
--- a/packages/google_mobile_ads/ios/google_mobile_ads.podspec
+++ b/packages/google_mobile_ads/ios/google_mobile_ads.podspec
@@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'google_mobile_ads'
- s.version = '6.0.0'
+ s.version = '7.0.0'
s.summary = 'Google Mobile Ads plugin for Flutter.'
s.description = <<-DESC
Google Mobile Ads plugin for Flutter.
@@ -15,7 +15,7 @@ Google Mobile Ads plugin for Flutter.
s.source_files = 'Classes/**/*.{h,m}'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
- s.dependency 'Google-Mobile-Ads-SDK','~> 12.2.0'
+ s.dependency 'Google-Mobile-Ads-SDK','~> 12.14.0'
s.dependency 'webview_flutter_wkwebview'
s.ios.deployment_target = '12.0'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS' => 'armv7 arm64 x86_64' }
diff --git a/packages/google_mobile_ads/lib/src/ad_containers.dart b/packages/google_mobile_ads/lib/src/ad_containers.dart
index 5303fc646..85ae6f0f1 100644
--- a/packages/google_mobile_ads/lib/src/ad_containers.dart
+++ b/packages/google_mobile_ads/lib/src/ad_containers.dart
@@ -65,12 +65,13 @@ class AdError {
class ResponseInfo {
/// Constructs a [ResponseInfo] with the [responseId] and [mediationAdapterClassName].
@protected
- const ResponseInfo(
- {this.responseId,
- this.mediationAdapterClassName,
- this.adapterResponses,
- this.loadedAdapterResponseInfo,
- required this.responseExtras});
+ const ResponseInfo({
+ this.responseId,
+ this.mediationAdapterClassName,
+ this.adapterResponses,
+ this.loadedAdapterResponseInfo,
+ required this.responseExtras,
+ });
/// An identifier for the loaded ad.
final String? responseId;
@@ -174,7 +175,7 @@ class LoadAdError extends AdError {
/// Default constructor for [LoadAdError].
@protected
LoadAdError(int code, String domain, String message, this.responseInfo)
- : super(code, domain, message);
+ : super(code, domain, message);
/// The [ResponseInfo] for the error.
final ResponseInfo? responseInfo;
@@ -192,16 +193,16 @@ class LoadAdError extends AdError {
/// [AdRequest.Builder for Android](https://developers.google.com/android/reference/com/google/android/gms/ads/AdRequest.Builder).
class AdRequest {
/// Default constructor for [AdRequest].
- const AdRequest(
- {this.keywords,
- this.contentUrl,
- this.neighboringContentUrls,
- this.nonPersonalizedAds,
- this.httpTimeoutMillis,
- @Deprecated('Use mediationExtras instead.')
- this.mediationExtrasIdentifier,
- this.extras,
- this.mediationExtras});
+ const AdRequest({
+ this.keywords,
+ this.contentUrl,
+ this.neighboringContentUrls,
+ this.nonPersonalizedAds,
+ this.httpTimeoutMillis,
+ @Deprecated('Use mediationExtras instead.') this.mediationExtrasIdentifier,
+ this.extras,
+ this.mediationExtras,
+ });
/// Words or phrases describing the current user activity.
final List? keywords;
@@ -256,15 +257,16 @@ class AdRequest {
@override
int get hashCode => Object.hash(
- keywords,
- contentUrl,
- nonPersonalizedAds,
- neighboringContentUrls,
- httpTimeoutMillis,
- //ignore: deprecated_member_use_from_same_package
- mediationExtrasIdentifier,
- extras,
- mediationExtras);
+ keywords,
+ contentUrl,
+ nonPersonalizedAds,
+ neighboringContentUrls,
+ httpTimeoutMillis,
+ //ignore: deprecated_member_use_from_same_package
+ mediationExtrasIdentifier,
+ extras,
+ mediationExtras,
+ );
}
/// Targeting info per the Ad Manager API.
@@ -283,16 +285,16 @@ class AdManagerAdRequest extends AdRequest {
Map? extras,
List? mediationExtras,
}) : super(
- keywords: keywords,
- contentUrl: contentUrl,
- neighboringContentUrls: neighboringContentUrls,
- nonPersonalizedAds: nonPersonalizedAds,
- httpTimeoutMillis: httpTimeoutMillis,
- //ignore: deprecated_member_use_from_same_package
- mediationExtrasIdentifier: mediationExtrasIdentifier,
- extras: extras,
- mediationExtras: mediationExtras,
- );
+ keywords: keywords,
+ contentUrl: contentUrl,
+ neighboringContentUrls: neighboringContentUrls,
+ nonPersonalizedAds: nonPersonalizedAds,
+ httpTimeoutMillis: httpTimeoutMillis,
+ //ignore: deprecated_member_use_from_same_package
+ mediationExtrasIdentifier: mediationExtrasIdentifier,
+ extras: extras,
+ mediationExtras: mediationExtras,
+ );
/// Key-value pairs used for custom targeting.
final Map? customTargeting;
@@ -391,8 +393,8 @@ class InlineAdaptiveSize extends AdSize {
int? get orientationValue => orientation == null
? null
: orientation == Orientation.portrait
- ? 0
- : 1;
+ ? 0
+ : 1;
}
/// [AdSize] represents the size of a banner ad.
@@ -403,10 +405,7 @@ class InlineAdaptiveSize extends AdSize {
/// additional details.
class AdSize {
/// Constructs an [AdSize] with the given [width] and [height].
- const AdSize({
- required this.width,
- required this.height,
- });
+ const AdSize({required this.width, required this.height});
/// The vertical span of an ad.
final int height;
@@ -445,10 +444,7 @@ class AdSize {
) async {
final num? height = await instanceManager.channel.invokeMethod(
'AdSize#getAnchoredAdaptiveBannerAdSize',
- {
- 'orientation': orientation.name,
- 'width': width,
- },
+ {'orientation': orientation.name, 'width': width},
);
if (height == null) return null;
@@ -466,12 +462,10 @@ class AdSize {
/// This function always returns the same height for any width / device combination.
/// For more details, visit: https://developers.google.com/android/reference/com/google/android/gms/ads/AdSize#getCurrentOrientationAnchoredAdaptiveBannerAdSize(android.content.Context,%20int)
static Future
- getCurrentOrientationAnchoredAdaptiveBannerAdSize(int width) async {
+ getCurrentOrientationAnchoredAdaptiveBannerAdSize(int width) async {
final num? height = await instanceManager.channel.invokeMethod(
'AdSize#getAnchoredAdaptiveBannerAdSize',
- {
- 'width': width,
- },
+ {'width': width},
);
if (height == null) return null;
@@ -493,7 +487,8 @@ class AdSize {
/// This ad size is most suitable for ads intended to be displayed inside
/// scrollable content.
static InlineAdaptiveSize getCurrentOrientationInlineAdaptiveBannerAdSize(
- int width) {
+ int width,
+ ) {
return InlineAdaptiveSize._(width: width);
}
@@ -509,7 +504,9 @@ class AdSize {
/// scrollable content.
static InlineAdaptiveSize getLandscapeInlineAdaptiveBannerAdSize(int width) {
return InlineAdaptiveSize._(
- width: width, orientation: Orientation.landscape);
+ width: width,
+ orientation: Orientation.landscape,
+ );
}
/// Gets an AdSize in portrait orientation with the given width and 0 height.
@@ -524,7 +521,9 @@ class AdSize {
/// scrollable content.
static InlineAdaptiveSize getPortraitInlineAdaptiveBannerAdSize(int width) {
return InlineAdaptiveSize._(
- width: width, orientation: Orientation.portrait);
+ width: width,
+ orientation: Orientation.portrait,
+ );
}
/// Gets an AdSize with the given width and height that is always 0.
@@ -537,7 +536,9 @@ class AdSize {
/// This ad size is most suitable for ads intended to be displayed inside
/// scrollable content.
static InlineAdaptiveSize getInlineAdaptiveBannerAdSize(
- int width, int maxHeight) {
+ int width,
+ int maxHeight,
+ ) {
return InlineAdaptiveSize._(width: width, maxHeight: maxHeight);
}
@@ -605,7 +606,7 @@ abstract class Ad {
abstract class AdWithView extends Ad {
/// Default constructor, used by subclasses.
AdWithView({required String adUnitId, required this.listener})
- : super(adUnitId: adUnitId);
+ : super(adUnitId: adUnitId);
/// The [AdWithViewListener] for the ad.
final AdWithViewListener listener;
@@ -693,18 +694,22 @@ class _AdWidgetState extends State {
throw FlutterError.fromParts([
ErrorSummary('This AdWidget is already in the Widget tree'),
ErrorHint(
- 'If you placed this AdWidget in a list, make sure you create a new instance '
- 'in the builder function with a unique ad object.'),
+ 'If you placed this AdWidget in a list, make sure you create a new instance '
+ 'in the builder function with a unique ad object.',
+ ),
ErrorHint(
- 'Make sure you are not using the same ad object in more than one AdWidget.'),
+ 'Make sure you are not using the same ad object in more than one AdWidget.',
+ ),
]);
}
if (_adLoadNotCalled) {
throw FlutterError.fromParts([
ErrorSummary(
- 'AdWidget requires Ad.load to be called before AdWidget is inserted into the tree'),
+ 'AdWidget requires Ad.load to be called before AdWidget is inserted into the tree',
+ ),
ErrorHint(
- 'Parameter ad is not loaded. Call Ad.load before AdWidget is inserted into the tree.'),
+ 'Parameter ad is not loaded. Call Ad.load before AdWidget is inserted into the tree.',
+ ),
]);
}
if (defaultTargetPlatform == TargetPlatform.android) {
@@ -712,20 +717,21 @@ class _AdWidgetState extends State {
viewType: '${instanceManager.channel.name}/ad_widget',
surfaceFactory:
(BuildContext context, PlatformViewController controller) {
- return AndroidViewSurface(
- controller: controller as AndroidViewController,
- gestureRecognizers: const >{},
- hitTestBehavior: PlatformViewHitTestBehavior.opaque,
- );
- },
+ return AndroidViewSurface(
+ controller: controller as AndroidViewController,
+ gestureRecognizers:
+ const >{},
+ hitTestBehavior: PlatformViewHitTestBehavior.opaque,
+ );
+ },
onCreatePlatformView: (PlatformViewCreationParams params) {
return PlatformViewsService.initSurfaceAndroidView(
- id: params.id,
- viewType: '${instanceManager.channel.name}/ad_widget',
- layoutDirection: TextDirection.ltr,
- creationParams: instanceManager.adIdFor(widget.ad),
- creationParamsCodec: StandardMessageCodec(),
- )
+ id: params.id,
+ viewType: '${instanceManager.channel.name}/ad_widget',
+ layoutDirection: TextDirection.ltr,
+ creationParams: instanceManager.adIdFor(widget.ad),
+ creationParamsCodec: StandardMessageCodec(),
+ )
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
..create();
},
@@ -746,7 +752,7 @@ class _AdWidgetState extends State {
class FluidAdWidget extends StatefulWidget {
/// Constructs a [FluidAdWidget].
const FluidAdWidget({Key? key, required this.ad, this.width})
- : super(key: key);
+ : super(key: key);
/// Ad to be displayed as a widget.
final FluidAdManagerBannerAd ad;
@@ -792,18 +798,22 @@ class _FluidAdWidgetState extends State {
throw FlutterError.fromParts([
ErrorSummary('This AdWidget is already in the Widget tree'),
ErrorHint(
- 'If you placed this AdWidget in a list, make sure you create a new instance '
- 'in the builder function with a unique ad object.'),
+ 'If you placed this AdWidget in a list, make sure you create a new instance '
+ 'in the builder function with a unique ad object.',
+ ),
ErrorHint(
- 'Make sure you are not using the same ad object in more than one AdWidget.'),
+ 'Make sure you are not using the same ad object in more than one AdWidget.',
+ ),
]);
}
if (_adLoadNotCalled) {
throw FlutterError.fromParts([
ErrorSummary(
- 'AdWidget requires Ad.load to be called before AdWidget is inserted into the tree'),
+ 'AdWidget requires Ad.load to be called before AdWidget is inserted into the tree',
+ ),
ErrorHint(
- 'Parameter ad is not loaded. Call Ad.load before AdWidget is inserted into the tree.'),
+ 'Parameter ad is not loaded. Call Ad.load before AdWidget is inserted into the tree.',
+ ),
]);
}
@@ -820,20 +830,21 @@ class _FluidAdWidgetState extends State {
viewType: '${instanceManager.channel.name}/ad_widget',
surfaceFactory:
(BuildContext context, PlatformViewController controller) {
- return AndroidViewSurface(
- controller: controller as AndroidViewController,
- gestureRecognizers: const >{},
- hitTestBehavior: PlatformViewHitTestBehavior.opaque,
- );
- },
+ return AndroidViewSurface(
+ controller: controller as AndroidViewController,
+ gestureRecognizers:
+ const >{},
+ hitTestBehavior: PlatformViewHitTestBehavior.opaque,
+ );
+ },
onCreatePlatformView: (PlatformViewCreationParams params) {
return PlatformViewsService.initSurfaceAndroidView(
- id: params.id,
- viewType: '${instanceManager.channel.name}/ad_widget',
- layoutDirection: TextDirection.ltr,
- creationParams: instanceManager.adIdFor(widget.ad),
- creationParamsCodec: StandardMessageCodec(),
- )
+ id: params.id,
+ viewType: '${instanceManager.channel.name}/ad_widget',
+ layoutDirection: TextDirection.ltr,
+ creationParams: instanceManager.adIdFor(widget.ad),
+ creationParamsCodec: StandardMessageCodec(),
+ )
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
..create();
},
@@ -927,11 +938,11 @@ class FluidAdManagerBannerAd extends AdManagerBannerAd {
required AdManagerAdRequest request,
this.onFluidAdHeightChangedListener,
}) : super(
- sizes: [FluidAdSize()],
- adUnitId: adUnitId,
- listener: listener,
- request: request,
- );
+ sizes: [FluidAdSize()],
+ adUnitId: adUnitId,
+ listener: listener,
+ request: request,
+ );
/// Listener for when the height of the ad changes.
OnFluidAdHeightChangedListener? onFluidAdHeightChangedListener;
@@ -955,8 +966,8 @@ class AdManagerBannerAd extends AdWithView {
required String adUnitId,
required this.listener,
required this.request,
- }) : assert(sizes.isNotEmpty),
- super(adUnitId: adUnitId, listener: listener);
+ }) : assert(sizes.isNotEmpty),
+ super(adUnitId: adUnitId, listener: listener);
/// Targeting information used to fetch an [Ad].
final AdManagerAdRequest request;
@@ -1023,10 +1034,10 @@ class NativeAd extends AdWithView {
this.nativeAdOptions,
this.customOptions,
this.nativeTemplateStyle,
- }) : adManagerRequest = null,
- assert(request != null),
- assert(nativeTemplateStyle != null || factoryId != null),
- super(adUnitId: adUnitId, listener: listener);
+ }) : adManagerRequest = null,
+ assert(request != null),
+ assert(nativeTemplateStyle != null || factoryId != null),
+ super(adUnitId: adUnitId, listener: listener);
/// Creates a [NativeAd] with Ad Manager.
///
@@ -1042,10 +1053,10 @@ class NativeAd extends AdWithView {
this.nativeAdOptions,
this.customOptions,
this.nativeTemplateStyle,
- }) : request = null,
- assert(adManagerRequest != null),
- assert(nativeTemplateStyle != null || factoryId != null),
- super(adUnitId: adUnitId, listener: listener);
+ }) : request = null,
+ assert(adManagerRequest != null),
+ assert(nativeTemplateStyle != null || factoryId != null),
+ super(adUnitId: adUnitId, listener: listener);
/// An identifier for the factory that creates the Platform view.
final String? factoryId;
@@ -1109,7 +1120,10 @@ class InterstitialAd extends AdWithoutView {
required InterstitialAdLoadCallback adLoadCallback,
}) async {
InterstitialAd ad = InterstitialAd._(
- adUnitId: adUnitId, adLoadCallback: adLoadCallback, request: request);
+ adUnitId: adUnitId,
+ adLoadCallback: adLoadCallback,
+ request: request,
+ );
await instanceManager.loadInterstitialAd(ad);
}
@@ -1155,7 +1169,10 @@ class AdManagerInterstitialAd extends AdWithoutView {
AppEventListener? appEventListener,
}) async {
AdManagerInterstitialAd ad = AdManagerInterstitialAd._(
- adUnitId: adUnitId, adLoadCallback: adLoadCallback, request: request);
+ adUnitId: adUnitId,
+ adLoadCallback: adLoadCallback,
+ request: request,
+ );
await instanceManager.loadAdManagerInterstitialAd(ad);
}
@@ -1181,8 +1198,8 @@ class RewardedAd extends AdWithoutView {
required String adUnitId,
required this.rewardedAdLoadCallback,
required this.request,
- }) : adManagerRequest = null,
- super(adUnitId: adUnitId);
+ }) : adManagerRequest = null,
+ super(adUnitId: adUnitId);
/// Creates a [RewardedAd] with a [AdManagerAdRequest].
///
@@ -1191,8 +1208,8 @@ class RewardedAd extends AdWithoutView {
required String adUnitId,
required this.rewardedAdLoadCallback,
required this.adManagerRequest,
- }) : request = null,
- super(adUnitId: adUnitId);
+ }) : request = null,
+ super(adUnitId: adUnitId);
/// Targeting information used to fetch an [Ad].
final AdRequest? request;
@@ -1216,9 +1233,10 @@ class RewardedAd extends AdWithoutView {
required RewardedAdLoadCallback rewardedAdLoadCallback,
}) async {
RewardedAd rewardedAd = RewardedAd._(
- adUnitId: adUnitId,
- request: request,
- rewardedAdLoadCallback: rewardedAdLoadCallback);
+ adUnitId: adUnitId,
+ request: request,
+ rewardedAdLoadCallback: rewardedAdLoadCallback,
+ );
await instanceManager.loadRewardedAd(rewardedAd);
}
@@ -1230,9 +1248,10 @@ class RewardedAd extends AdWithoutView {
required RewardedAdLoadCallback rewardedAdLoadCallback,
}) async {
RewardedAd rewardedAd = RewardedAd._fromAdManagerRequest(
- adUnitId: adUnitId,
- adManagerRequest: adManagerRequest,
- rewardedAdLoadCallback: rewardedAdLoadCallback);
+ adUnitId: adUnitId,
+ adManagerRequest: adManagerRequest,
+ rewardedAdLoadCallback: rewardedAdLoadCallback,
+ );
await instanceManager.loadRewardedAd(rewardedAd);
}
@@ -1270,8 +1289,8 @@ class RewardedInterstitialAd extends AdWithoutView {
required String adUnitId,
required this.rewardedInterstitialAdLoadCallback,
required this.request,
- }) : adManagerRequest = null,
- super(adUnitId: adUnitId);
+ }) : adManagerRequest = null,
+ super(adUnitId: adUnitId);
/// Creates a [RewardedInterstitialAd] with an [AdManagerAdRequest].
///
@@ -1280,8 +1299,8 @@ class RewardedInterstitialAd extends AdWithoutView {
required String adUnitId,
required this.rewardedInterstitialAdLoadCallback,
required this.adManagerRequest,
- }) : request = null,
- super(adUnitId: adUnitId);
+ }) : request = null,
+ super(adUnitId: adUnitId);
/// Targeting information used to fetch an [Ad].
final AdRequest? request;
@@ -1303,12 +1322,13 @@ class RewardedInterstitialAd extends AdWithoutView {
required String adUnitId,
required AdRequest request,
required RewardedInterstitialAdLoadCallback
- rewardedInterstitialAdLoadCallback,
+ rewardedInterstitialAdLoadCallback,
}) async {
RewardedInterstitialAd rewardedInterstitialAd = RewardedInterstitialAd._(
- adUnitId: adUnitId,
- request: request,
- rewardedInterstitialAdLoadCallback: rewardedInterstitialAdLoadCallback);
+ adUnitId: adUnitId,
+ request: request,
+ rewardedInterstitialAdLoadCallback: rewardedInterstitialAdLoadCallback,
+ );
await instanceManager.loadRewardedInterstitialAd(rewardedInterstitialAd);
}
@@ -1318,14 +1338,15 @@ class RewardedInterstitialAd extends AdWithoutView {
required String adUnitId,
required AdManagerAdRequest adManagerRequest,
required RewardedInterstitialAdLoadCallback
- rewardedInterstitialAdLoadCallback,
+ rewardedInterstitialAdLoadCallback,
}) async {
RewardedInterstitialAd rewardedInterstitialAd =
RewardedInterstitialAd._fromAdManagerRequest(
- adUnitId: adUnitId,
- adManagerRequest: adManagerRequest,
- rewardedInterstitialAdLoadCallback:
- rewardedInterstitialAdLoadCallback);
+ adUnitId: adUnitId,
+ adManagerRequest: adManagerRequest,
+ rewardedInterstitialAdLoadCallback:
+ rewardedInterstitialAdLoadCallback,
+ );
await instanceManager.loadRewardedInterstitialAd(rewardedInterstitialAd);
}
@@ -1394,15 +1415,15 @@ class AppOpenAd extends AdWithoutView {
required String adUnitId,
required this.adLoadCallback,
required this.request,
- }) : adManagerAdRequest = null,
- super(adUnitId: adUnitId);
+ }) : adManagerAdRequest = null,
+ super(adUnitId: adUnitId);
AppOpenAd._fromAdManagerRequest({
required String adUnitId,
required this.adLoadCallback,
required this.adManagerAdRequest,
- }) : request = null,
- super(adUnitId: adUnitId);
+ }) : request = null,
+ super(adUnitId: adUnitId);
/// The [AdRequest] used to load the ad.
final AdRequest? request;
@@ -1468,7 +1489,7 @@ enum MediaAspectRatio {
portrait,
/// Close to square media aspect ratio. This is not a strict 1:1 aspect ratio.
- square
+ square,
}
/// Indicates preferred location of AdChoices icon.
@@ -1483,7 +1504,7 @@ enum AdChoicesPlacement {
bottomRightCorner,
/// Bottom left corner.
- bottomLeftCorner
+ bottomLeftCorner,
}
/// Used to configure native ad requests.
@@ -1541,12 +1562,13 @@ class NativeAdOptions {
@override
int get hashCode => Object.hash(
- adChoicesPlacement,
- mediaAspectRatio,
- videoOptions,
- requestCustomMuteThisAd,
- shouldRequestMultipleImages,
- shouldReturnUrlsForImageAssets);
+ adChoicesPlacement,
+ mediaAspectRatio,
+ videoOptions,
+ requestCustomMuteThisAd,
+ shouldRequestMultipleImages,
+ shouldReturnUrlsForImageAssets,
+ );
}
/// Options for controlling video playback in supported ad formats.
diff --git a/packages/google_mobile_ads/lib/src/ad_inspector_containers.dart b/packages/google_mobile_ads/lib/src/ad_inspector_containers.dart
index d3e118a89..cfc42daab 100644
--- a/packages/google_mobile_ads/lib/src/ad_inspector_containers.dart
+++ b/packages/google_mobile_ads/lib/src/ad_inspector_containers.dart
@@ -18,11 +18,7 @@ typedef OnAdInspectorClosedListener = void Function(AdInspectorError?);
/// Error information about why the ad inspector failed.
class AdInspectorError {
/// Create an AdInspectorError with the given code, domain and message.
- AdInspectorError({
- this.code,
- this.domain,
- this.message,
- });
+ AdInspectorError({this.code, this.domain, this.message});
/// Code to identifier the error.
final String? code;
diff --git a/packages/google_mobile_ads/lib/src/ad_instance_manager.dart b/packages/google_mobile_ads/lib/src/ad_instance_manager.dart
index b5061bbea..aa37a30a0 100644
--- a/packages/google_mobile_ads/lib/src/ad_instance_manager.dart
+++ b/packages/google_mobile_ads/lib/src/ad_instance_manager.dart
@@ -50,12 +50,13 @@ AdInstanceManager instanceManager = AdInstanceManager(
/// Maintains access to loaded [Ad] instances and handles sending/receiving
/// messages to platform code.
class AdInstanceManager {
- AdInstanceManager(String channelName,
- {this.webViewControllerUtil = const WebViewControllerUtil()})
- : channel = MethodChannel(
- channelName,
- StandardMethodCodec(AdMessageCodec()),
- ) {
+ AdInstanceManager(
+ String channelName, {
+ this.webViewControllerUtil = const WebViewControllerUtil(),
+ }) : channel = MethodChannel(
+ channelName,
+ StandardMethodCodec(AdMessageCodec()),
+ ) {
channel.setMethodCallHandler((MethodCall call) async {
assert(call.method == 'onAdEvent');
@@ -133,20 +134,25 @@ class AdInstanceManager {
break;
case 'adWillDismissFullScreenContent':
if (ad is RewardedAd) {
- ad.fullScreenContentCallback?.onAdWillDismissFullScreenContent
- ?.call(ad);
+ ad.fullScreenContentCallback?.onAdWillDismissFullScreenContent?.call(
+ ad,
+ );
} else if (ad is InterstitialAd) {
- ad.fullScreenContentCallback?.onAdWillDismissFullScreenContent
- ?.call(ad);
+ ad.fullScreenContentCallback?.onAdWillDismissFullScreenContent?.call(
+ ad,
+ );
} else if (ad is RewardedInterstitialAd) {
- ad.fullScreenContentCallback?.onAdWillDismissFullScreenContent
- ?.call(ad);
+ ad.fullScreenContentCallback?.onAdWillDismissFullScreenContent?.call(
+ ad,
+ );
} else if (ad is AdManagerInterstitialAd) {
- ad.fullScreenContentCallback?.onAdWillDismissFullScreenContent
- ?.call(ad);
+ ad.fullScreenContentCallback?.onAdWillDismissFullScreenContent?.call(
+ ad,
+ );
} else if (ad is AppOpenAd) {
- ad.fullScreenContentCallback?.onAdWillDismissFullScreenContent
- ?.call(ad);
+ ad.fullScreenContentCallback?.onAdWillDismissFullScreenContent?.call(
+ ad,
+ );
} else {
debugPrint('invalid ad: $ad, for event name: $eventName');
}
@@ -166,7 +172,10 @@ class AdInstanceManager {
}
void _onAdEventAndroid(
- Ad ad, String eventName, Map arguments) {
+ Ad ad,
+ String eventName,
+ Map arguments,
+ ) {
switch (eventName) {
case 'onAdLoaded':
_invokeOnAdLoaded(ad, eventName, arguments);
@@ -215,13 +224,17 @@ class AdInstanceManager {
void _invokeFluidAdHeightChanged(Ad ad, Map arguments) {
assert(ad is FluidAdManagerBannerAd);
- (ad as FluidAdManagerBannerAd)
- .onFluidAdHeightChangedListener
- ?.call(ad, arguments['height'].toDouble());
+ (ad as FluidAdManagerBannerAd).onFluidAdHeightChangedListener?.call(
+ ad,
+ arguments['height'].toDouble(),
+ );
}
void _invokeOnAdLoaded(
- Ad ad, String eventName, Map arguments) {
+ Ad ad,
+ String eventName,
+ Map arguments,
+ ) {
ad.responseInfo = arguments['responseInfo'];
if (ad is AdWithView) {
ad.listener.onAdLoaded?.call(ad);
@@ -241,7 +254,10 @@ class AdInstanceManager {
}
void _invokeOnAdFailedToLoad(
- Ad ad, String eventName, Map arguments) {
+ Ad ad,
+ String eventName,
+ Map arguments,
+ ) {
if (ad is AdWithView) {
ad.listener.onAdFailedToLoad?.call(ad, arguments['loadAdError']);
} else if (ad is RewardedAd) {
@@ -252,8 +268,9 @@ class AdInstanceManager {
ad.adLoadCallback.onAdFailedToLoad.call(arguments['loadAdError']);
} else if (ad is RewardedInterstitialAd) {
ad.dispose();
- ad.rewardedInterstitialAdLoadCallback.onAdFailedToLoad
- .call(arguments['loadAdError']);
+ ad.rewardedInterstitialAdLoadCallback.onAdFailedToLoad.call(
+ arguments['loadAdError'],
+ );
} else if (ad is AdManagerInterstitialAd) {
ad.dispose();
ad.adLoadCallback.onAdFailedToLoad.call(arguments['loadAdError']);
@@ -265,19 +282,28 @@ class AdInstanceManager {
}
void _invokeOnAppEvent(
- Ad ad, String eventName, Map arguments) {
+ Ad ad,
+ String eventName,
+ Map arguments,
+ ) {
if (ad is AdManagerBannerAd) {
ad.listener.onAppEvent?.call(ad, arguments['name'], arguments['data']);
} else if (ad is AdManagerInterstitialAd) {
- ad.appEventListener?.onAppEvent
- ?.call(ad, arguments['name'], arguments['data']);
+ ad.appEventListener?.onAppEvent?.call(
+ ad,
+ arguments['name'],
+ arguments['data'],
+ );
} else {
debugPrint('invalid ad: $ad, for event name: $eventName');
}
}
void _invokeOnUserEarnedReward(
- Ad ad, String eventName, Map arguments) {
+ Ad ad,
+ String eventName,
+ Map arguments,
+ ) {
assert(arguments['rewardItem'] != null);
if (ad is RewardedAd) {
ad.onUserEarnedRewardCallback?.call(ad, arguments['rewardItem']);
@@ -337,22 +363,35 @@ class AdInstanceManager {
}
void _invokeOnAdFailedToShowFullScreenContent(
- Ad ad, String eventName, Map arguments) {
+ Ad ad,
+ String eventName,
+ Map arguments,
+ ) {
if (ad is RewardedAd) {
- ad.fullScreenContentCallback?.onAdFailedToShowFullScreenContent
- ?.call(ad, arguments['error']);
+ ad.fullScreenContentCallback?.onAdFailedToShowFullScreenContent?.call(
+ ad,
+ arguments['error'],
+ );
} else if (ad is InterstitialAd) {
- ad.fullScreenContentCallback?.onAdFailedToShowFullScreenContent
- ?.call(ad, arguments['error']);
+ ad.fullScreenContentCallback?.onAdFailedToShowFullScreenContent?.call(
+ ad,
+ arguments['error'],
+ );
} else if (ad is RewardedInterstitialAd) {
- ad.fullScreenContentCallback?.onAdFailedToShowFullScreenContent
- ?.call(ad, arguments['error']);
+ ad.fullScreenContentCallback?.onAdFailedToShowFullScreenContent?.call(
+ ad,
+ arguments['error'],
+ );
} else if (ad is AdManagerInterstitialAd) {
- ad.fullScreenContentCallback?.onAdFailedToShowFullScreenContent
- ?.call(ad, arguments['error']);
+ ad.fullScreenContentCallback?.onAdFailedToShowFullScreenContent?.call(
+ ad,
+ arguments['error'],
+ );
} else if (ad is AppOpenAd) {
- ad.fullScreenContentCallback?.onAdFailedToShowFullScreenContent
- ?.call(ad, arguments['error']);
+ ad.fullScreenContentCallback?.onAdFailedToShowFullScreenContent?.call(
+ ad,
+ arguments['error'],
+ );
} else {
debugPrint('invalid ad: $ad, for event name: $eventName');
}
@@ -397,7 +436,10 @@ class AdInstanceManager {
}
void _invokePaidEvent(
- Ad ad, String eventName, Map arguments) {
+ Ad ad,
+ String eventName,
+ Map arguments,
+ ) {
assert(arguments['valueMicros'] != null && arguments['valueMicros'] is num);
int precisionTypeInt = arguments['precision'];
@@ -448,9 +490,7 @@ class AdInstanceManager {
Future getAdSize(Ad ad) =>
instanceManager.channel.invokeMethod(
'getAdSize',
- {
- 'adId': adIdFor(ad),
- },
+ {'adId': adIdFor(ad)},
);
/// Returns null if an invalid [adId] was passed in.
@@ -480,15 +520,12 @@ class AdInstanceManager {
final int adId = _nextAdId++;
_loadedAds[adId] = ad;
- return channel.invokeMethod(
- 'loadBannerAd',
- {
- 'adId': adId,
- 'adUnitId': ad.adUnitId,
- 'request': ad.request,
- 'size': ad.size,
- },
- );
+ return channel.invokeMethod('loadBannerAd', {
+ 'adId': adId,
+ 'adUnitId': ad.adUnitId,
+ 'request': ad.request,
+ 'size': ad.size,
+ });
}
Future loadInterstitialAd(InterstitialAd ad) {
@@ -498,14 +535,11 @@ class AdInstanceManager {
final int adId = _nextAdId++;
_loadedAds[adId] = ad;
- return channel.invokeMethod(
- 'loadInterstitialAd',
- {
- 'adId': adId,
- 'adUnitId': ad.adUnitId,
- 'request': ad.request,
- },
- );
+ return channel.invokeMethod('loadInterstitialAd', {
+ 'adId': adId,
+ 'adUnitId': ad.adUnitId,
+ 'request': ad.request,
+ });
}
/// Starts loading the ad if not previously loaded.
@@ -518,19 +552,16 @@ class AdInstanceManager {
final int adId = _nextAdId++;
_loadedAds[adId] = ad;
- return channel.invokeMethod(
- 'loadNativeAd',
- {
- 'adId': adId,
- 'adUnitId': ad.adUnitId,
- 'request': ad.request,
- 'adManagerRequest': ad.adManagerRequest,
- 'factoryId': ad.factoryId,
- 'nativeAdOptions': ad.nativeAdOptions,
- 'customOptions': ad.customOptions,
- 'nativeTemplateStyle': ad.nativeTemplateStyle,
- },
- );
+ return channel.invokeMethod('loadNativeAd', {
+ 'adId': adId,
+ 'adUnitId': ad.adUnitId,
+ 'request': ad.request,
+ 'adManagerRequest': ad.adManagerRequest,
+ 'factoryId': ad.factoryId,
+ 'nativeAdOptions': ad.nativeAdOptions,
+ 'customOptions': ad.customOptions,
+ 'nativeTemplateStyle': ad.nativeTemplateStyle,
+ });
}
/// Starts loading the ad if not previously loaded.
@@ -543,15 +574,12 @@ class AdInstanceManager {
final int adId = _nextAdId++;
_loadedAds[adId] = ad;
- return channel.invokeMethod(
- 'loadRewardedAd',
- {
- 'adId': adId,
- 'adUnitId': ad.adUnitId,
- 'request': ad.request,
- 'adManagerRequest': ad.adManagerRequest,
- },
- );
+ return channel.invokeMethod('loadRewardedAd', {
+ 'adId': adId,
+ 'adUnitId': ad.adUnitId,
+ 'request': ad.request,
+ 'adManagerRequest': ad.adManagerRequest,
+ });
}
/// Starts loading the ad if not previously loaded.
@@ -564,15 +592,13 @@ class AdInstanceManager {
final int adId = _nextAdId++;
_loadedAds[adId] = ad;
- return channel.invokeMethod(
- 'loadRewardedInterstitialAd',
- {
- 'adId': adId,
- 'adUnitId': ad.adUnitId,
- 'request': ad.request,
- 'adManagerRequest': ad.adManagerRequest,
- },
- );
+ return channel
+ .invokeMethod('loadRewardedInterstitialAd', {
+ 'adId': adId,
+ 'adUnitId': ad.adUnitId,
+ 'request': ad.request,
+ 'adManagerRequest': ad.adManagerRequest,
+ });
}
/// Load an app open ad.
@@ -583,15 +609,12 @@ class AdInstanceManager {
final int adId = _nextAdId++;
_loadedAds[adId] = ad;
- return channel.invokeMethod(
- 'loadAppOpenAd',
- {
- 'adId': adId,
- 'adUnitId': ad.adUnitId,
- 'request': ad.request,
- 'adManagerRequest': ad.adManagerAdRequest,
- },
- );
+ return channel.invokeMethod('loadAppOpenAd', {
+ 'adId': adId,
+ 'adUnitId': ad.adUnitId,
+ 'request': ad.request,
+ 'adManagerRequest': ad.adManagerAdRequest,
+ });
}
/// Starts loading the ad if not previously loaded.
@@ -625,15 +648,12 @@ class AdInstanceManager {
final int adId = _nextAdId++;
_loadedAds[adId] = ad;
- return channel.invokeMethod(
- 'loadFluidAd',
- {
- 'adId': adId,
- 'sizes': ad.sizes,
- 'adUnitId': ad.adUnitId,
- 'request': ad.request,
- },
- );
+ return channel.invokeMethod('loadFluidAd', {
+ 'adId': adId,
+ 'sizes': ad.sizes,
+ 'adUnitId': ad.adUnitId,
+ 'request': ad.request,
+ });
}
/// Loads an ad if not currently loading or loaded.
@@ -666,12 +686,9 @@ class AdInstanceManager {
if (disposedAd == null) {
return Future.value();
}
- return channel.invokeMethod(
- 'disposeAd',
- {
- 'adId': adId,
- },
- );
+ return channel.invokeMethod('disposeAd', {
+ 'adId': adId,
+ });
}
/// Display an [AdWithoutView] that is overlaid on top of the application.
@@ -681,23 +698,22 @@ class AdInstanceManager {
'$Ad has not been loaded or has already been disposed.',
);
- return channel.invokeMethod(
- 'showAdWithoutView',
- {
- 'adId': adIdFor(ad),
- },
- );
+ return channel.invokeMethod('showAdWithoutView', {
+ 'adId': adIdFor(ad),
+ });
}
/// Gets the global [RequestConfiguration].
Future getRequestConfiguration() async {
return (await instanceManager.channel.invokeMethod(
- 'MobileAds#getRequestConfiguration'))!;
+ 'MobileAds#getRequestConfiguration',
+ ))!;
}
/// Set the [RequestConfiguration] to apply for future ad requests.
Future updateRequestConfiguration(
- RequestConfiguration requestConfiguration) {
+ RequestConfiguration requestConfiguration,
+ ) {
return channel.invokeMethod(
'MobileAds#updateRequestConfiguration',
{
@@ -714,9 +730,7 @@ class AdInstanceManager {
Future setSameAppKeyEnabled(bool isEnabled) {
return channel.invokeMethod(
'MobileAds#setSameAppKeyEnabled',
- {
- 'isEnabled': isEnabled,
- },
+ {'isEnabled': isEnabled},
);
}
@@ -724,9 +738,7 @@ class AdInstanceManager {
Future setAppMuted(bool muted) {
return channel.invokeMethod(
'MobileAds#setAppMuted',
- {
- 'muted': muted,
- },
+ {'muted': muted},
);
}
@@ -734,9 +746,7 @@ class AdInstanceManager {
Future setAppVolume(double volume) {
return channel.invokeMethod(
'MobileAds#setAppVolume',
- {
- 'volume': volume,
- },
+ {'volume': volume},
);
}
@@ -747,13 +757,10 @@ class AdInstanceManager {
'$ad has not been loaded or has already been disposed.',
);
- return channel.invokeMethod(
- 'setImmersiveMode',
- {
- 'adId': adIdFor(ad),
- 'immersiveModeEnabled': immersiveModeEnabled,
- },
- );
+ return channel.invokeMethod('setImmersiveMode', {
+ 'adId': adIdFor(ad),
+ 'immersiveModeEnabled': immersiveModeEnabled,
+ });
}
/// Disables automated SDK crash reporting.
@@ -763,14 +770,16 @@ class AdInstanceManager {
/// Disables mediation adapter initialization during initialization of the GMA SDK.
Future disableMediationInitialization() {
- return channel
- .invokeMethod('MobileAds#disableMediationInitialization');
+ return channel.invokeMethod(
+ 'MobileAds#disableMediationInitialization',
+ );
}
/// Gets the version string of Google Mobile Ads SDK.
Future getVersionString() async {
- return (await instanceManager.channel
- .invokeMethod('MobileAds#getVersionString'))!;
+ return (await instanceManager.channel.invokeMethod(
+ 'MobileAds#getVersionString',
+ ))!;
}
/// Set server side verification options on the ad.
@@ -794,9 +803,7 @@ class AdInstanceManager {
Future openDebugMenu(String adUnitId) async {
return channel.invokeMethod(
'MobileAds#openDebugMenu',
- {
- 'adUnitId': adUnitId,
- },
+ {'adUnitId': adUnitId},
);
}
@@ -827,8 +834,11 @@ class AdInstanceManager {
await channel.invokeMethod('MobileAds#openAdInspector');
listener(null);
} on PlatformException catch (e) {
- var error =
- AdInspectorError(code: e.code, domain: e.details, message: e.message);
+ var error = AdInspectorError(
+ code: e.code,
+ domain: e.details,
+ message: e.message,
+ );
listener(error);
}
}
@@ -1016,15 +1026,20 @@ class AdMessageCodec extends StandardMessageCodec {
: AdSize.getLandscapeInlineAdaptiveBannerAdSize(width.toInt());
} else if (maxHeight != null) {
return AdSize.getInlineAdaptiveBannerAdSize(
- width.toInt(), maxHeight.toInt());
+ width.toInt(),
+ maxHeight.toInt(),
+ );
} else {
return AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(
- width.toInt());
+ width.toInt(),
+ );
}
case _valueAnchoredAdaptiveBannerAdSize:
- final String? orientationStr =
- readValueOfType(buffer.getUint8(), buffer);
+ final String? orientationStr = readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ );
final num width = readValueOfType(buffer.getUint8(), buffer);
Orientation? orientation;
if (orientationStr != null) {
@@ -1038,8 +1053,10 @@ class AdMessageCodec extends StandardMessageCodec {
height: -1, // Unused value
);
case _valueSmartBannerAdSize:
- final String orientationStr =
- readValueOfType(buffer.getUint8(), buffer);
+ final String orientationStr = readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ );
return SmartBannerAdSize(
Orientation.values.firstWhere(
(Orientation orientation) => orientation.name == orientationStr,
@@ -1048,10 +1065,7 @@ class AdMessageCodec extends StandardMessageCodec {
case _valueAdSize:
num width = readValueOfType(buffer.getUint8(), buffer);
num height = readValueOfType(buffer.getUint8(), buffer);
- return AdSize(
- width: width.toInt(),
- height: height.toInt(),
- );
+ return AdSize(width: width.toInt(), height: height.toInt());
case _valueFluidAdSize:
return FluidAdSize();
case _valueAdRequest:
@@ -1059,20 +1073,28 @@ class AdMessageCodec extends StandardMessageCodec {
keywords: readValueOfType(buffer.getUint8(), buffer)?.cast(),
contentUrl: readValueOfType(buffer.getUint8(), buffer),
nonPersonalizedAds: readValueOfType(buffer.getUint8(), buffer),
- neighboringContentUrls:
- readValueOfType(buffer.getUint8(), buffer)?.cast(),
+ neighboringContentUrls: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ )?.cast(),
httpTimeoutMillis: (defaultTargetPlatform == TargetPlatform.android)
? readValueOfType(buffer.getUint8(), buffer)
: null,
mediationExtrasIdentifier: readValueOfType(buffer.getUint8(), buffer),
- extras: readValueOfType(buffer.getUint8(), buffer)
- ?.cast(),
- mediationExtras: readValueOfType(buffer.getUint8(), buffer)
- ?.cast>(),
+ extras: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ )?.cast(),
+ mediationExtras: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ )?.cast>(),
);
case _valueMediationExtras:
- return _MediationExtras(readValueOfType(buffer.getUint8(), buffer),
- readValueOfType(buffer.getUint8(), buffer));
+ return _MediationExtras(
+ readValueOfType(buffer.getUint8(), buffer),
+ readValueOfType(buffer.getUint8(), buffer),
+ );
case _valueRewardItem:
return RewardItem(
readValueOfType(buffer.getUint8(), buffer),
@@ -1082,24 +1104,29 @@ class AdMessageCodec extends StandardMessageCodec {
return ResponseInfo(
responseId: readValueOfType(buffer.getUint8(), buffer),
mediationAdapterClassName: readValueOfType(buffer.getUint8(), buffer),
- adapterResponses: readValueOfType(buffer.getUint8(), buffer)
- ?.cast(),
+ adapterResponses: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ )?.cast(),
loadedAdapterResponseInfo: readValueOfType(buffer.getUint8(), buffer),
responseExtras: _deepCastStringKeyDynamicValueMap(
- readValueOfType(buffer.getUint8(), buffer)),
+ readValueOfType(buffer.getUint8(), buffer),
+ ),
);
case _valueAdapterResponseInfo:
return AdapterResponseInfo(
- adapterClassName: _safeReadString(buffer),
- latencyMillis: readValueOfType(buffer.getUint8(), buffer),
- description: _safeReadString(buffer),
- adUnitMapping:
- _deepCastStringMap(readValueOfType(buffer.getUint8(), buffer)),
- adError: readValueOfType(buffer.getUint8(), buffer),
- adSourceName: _safeReadString(buffer),
- adSourceId: _safeReadString(buffer),
- adSourceInstanceName: _safeReadString(buffer),
- adSourceInstanceId: _safeReadString(buffer));
+ adapterClassName: _safeReadString(buffer),
+ latencyMillis: readValueOfType(buffer.getUint8(), buffer),
+ description: _safeReadString(buffer),
+ adUnitMapping: _deepCastStringMap(
+ readValueOfType(buffer.getUint8(), buffer),
+ ),
+ adError: readValueOfType(buffer.getUint8(), buffer),
+ adSourceName: _safeReadString(buffer),
+ adSourceId: _safeReadString(buffer),
+ adSourceInstanceName: _safeReadString(buffer),
+ adSourceInstanceId: _safeReadString(buffer),
+ );
case _valueLoadAdError:
return LoadAdError(
readValueOfType(buffer.getUint8(), buffer),
@@ -1109,30 +1136,39 @@ class AdMessageCodec extends StandardMessageCodec {
);
case _valueAdError:
return AdError(
- readValueOfType(buffer.getUint8(), buffer),
- readValueOfType(buffer.getUint8(), buffer),
- readValueOfType(buffer.getUint8(), buffer));
+ readValueOfType(buffer.getUint8(), buffer),
+ readValueOfType(buffer.getUint8(), buffer),
+ readValueOfType(buffer.getUint8(), buffer),
+ );
case _valueAdManagerAdRequest:
return AdManagerAdRequest(
keywords: readValueOfType(buffer.getUint8(), buffer)?.cast(),
contentUrl: readValueOfType(buffer.getUint8(), buffer),
- customTargeting: readValueOfType(buffer.getUint8(), buffer)
- ?.cast(),
+ customTargeting: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ )?.cast(),
customTargetingLists: _tryDeepMapCast(
readValueOfType(buffer.getUint8(), buffer),
),
nonPersonalizedAds: readValueOfType(buffer.getUint8(), buffer),
- neighboringContentUrls:
- readValueOfType(buffer.getUint8(), buffer)?.cast(),
+ neighboringContentUrls: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ )?.cast(),
httpTimeoutMillis: (defaultTargetPlatform == TargetPlatform.android)
? readValueOfType(buffer.getUint8(), buffer)
: null,
publisherProvidedId: readValueOfType(buffer.getUint8(), buffer),
mediationExtrasIdentifier: readValueOfType(buffer.getUint8(), buffer),
- extras: readValueOfType(buffer.getUint8(), buffer)
- ?.cast(),
- mediationExtras: readValueOfType(buffer.getUint8(), buffer)
- ?.cast>(),
+ extras: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ )?.cast(),
+ mediationExtras: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ )?.cast>(),
);
case _valueInitializationState:
switch (readValueOfType(buffer.getUint8(), buffer)) {
@@ -1143,8 +1179,10 @@ class AdMessageCodec extends StandardMessageCodec {
}
throw ArgumentError();
case _valueAdapterStatus:
- final AdapterInitializationState state =
- readValueOfType(buffer.getUint8(), buffer);
+ final AdapterInitializationState state = readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ );
final String description = readValueOfType(buffer.getUint8(), buffer);
double latency = readValueOfType(buffer.getUint8(), buffer).toDouble();
@@ -1157,13 +1195,16 @@ class AdMessageCodec extends StandardMessageCodec {
return AdapterStatus(state, description, latency);
case _valueInitializationStatus:
return InitializationStatus(
- readValueOfType(buffer.getUint8(), buffer)
- .cast(),
+ readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ ).cast(),
);
case _valueServerSideVerificationOptions:
return ServerSideVerificationOptions(
- userId: readValueOfType(buffer.getUint8(), buffer),
- customData: readValueOfType(buffer.getUint8(), buffer));
+ userId: readValueOfType(buffer.getUint8(), buffer),
+ customData: readValueOfType(buffer.getUint8(), buffer),
+ );
case _valueNativeAdOptions:
int? adChoices = readValueOfType(buffer.getUint8(), buffer);
int? mediaAspectRatio = readValueOfType(buffer.getUint8(), buffer);
@@ -1172,10 +1213,14 @@ class AdMessageCodec extends StandardMessageCodec {
mediaAspectRatio: MediaAspectRatioExtension.fromInt(mediaAspectRatio),
videoOptions: readValueOfType(buffer.getUint8(), buffer),
requestCustomMuteThisAd: readValueOfType(buffer.getUint8(), buffer),
- shouldRequestMultipleImages:
- readValueOfType(buffer.getUint8(), buffer),
- shouldReturnUrlsForImageAssets:
- readValueOfType(buffer.getUint8(), buffer),
+ shouldRequestMultipleImages: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ ),
+ shouldReturnUrlsForImageAssets: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ ),
);
case _valueVideoOptions:
return VideoOptions(
@@ -1186,11 +1231,15 @@ class AdMessageCodec extends StandardMessageCodec {
case _valueRequestConfigurationParams:
return RequestConfiguration(
maxAdContentRating: readValueOfType(buffer.getUint8(), buffer),
- tagForChildDirectedTreatment:
- readValueOfType(buffer.getUint8(), buffer),
+ tagForChildDirectedTreatment: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ ),
tagForUnderAgeOfConsent: readValueOfType(buffer.getUint8(), buffer),
- testDeviceIds:
- readValueOfType(buffer.getUint8(), buffer).cast(),
+ testDeviceIds: readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ ).cast(),
);
case _valueNativeTemplateStyle:
return NativeTemplateStyle(
@@ -1215,13 +1264,16 @@ class AdMessageCodec extends StandardMessageCodec {
);
case _valueColor:
return Color.fromARGB(
- readValueOfType(buffer.getUint8(), buffer),
- readValueOfType(buffer.getUint8(), buffer),
- readValueOfType(buffer.getUint8(), buffer),
- readValueOfType(buffer.getUint8(), buffer));
+ readValueOfType(buffer.getUint8(), buffer),
+ readValueOfType(buffer.getUint8(), buffer),
+ readValueOfType(buffer.getUint8(), buffer),
+ readValueOfType(buffer.getUint8(), buffer),
+ );
case _valueNativeTemplateFontStyle:
- return NativeTemplateFontStyle
- .values[readValueOfType(buffer.getUint8(), buffer)];
+ return NativeTemplateFontStyle.values[readValueOfType(
+ buffer.getUint8(),
+ buffer,
+ )];
default:
return super.readValueOfType(type, buffer);
}
@@ -1230,31 +1282,24 @@ class AdMessageCodec extends StandardMessageCodec {
Map>? _tryDeepMapCast(Map? map) {
if (map == null) return null;
return map.map>(
- (dynamic key, dynamic value) => MapEntry>(
- key,
- value?.cast(),
- ),
+ (dynamic key, dynamic value) =>
+ MapEntry>(key, value?.cast()),
);
}
Map _deepCastStringMap(Map? map) {
if (map == null) return {};
return map.map(
- (dynamic key, dynamic value) => MapEntry(
- key,
- value,
- ),
+ (dynamic key, dynamic value) => MapEntry(key, value),
);
}
Map _deepCastStringKeyDynamicValueMap(
- Map? map) {
+ Map? map,
+ ) {
if (map == null) return {};
return map.map(
- (dynamic key, dynamic value) => MapEntry(
- key,
- value,
- ),
+ (dynamic key, dynamic value) => MapEntry(key, value),
);
}
@@ -1295,12 +1340,10 @@ class AdMessageCodec extends StandardMessageCodec {
}
class _MediationExtras implements MediationExtras {
- _MediationExtras(
- String className,
- Map extras,
- ) : _androidClassName = className,
- _iOSClassName = className,
- _extras = extras;
+ _MediationExtras(String className, Map extras)
+ : _androidClassName = className,
+ _iOSClassName = className,
+ _extras = extras;
final String _androidClassName;
final String _iOSClassName;
diff --git a/packages/google_mobile_ads/lib/src/ad_listeners.dart b/packages/google_mobile_ads/lib/src/ad_listeners.dart
index 5677a2469..2645bf98c 100644
--- a/packages/google_mobile_ads/lib/src/ad_listeners.dart
+++ b/packages/google_mobile_ads/lib/src/ad_listeners.dart
@@ -26,19 +26,24 @@ typedef GenericAdEventCallback = void Function(Ad ad);
typedef FullScreenAdLoadErrorCallback = void Function(LoadAdError error);
/// The callback type for when a user earns a reward.
-typedef OnUserEarnedRewardCallback = void Function(
- AdWithoutView ad, RewardItem reward);
+typedef OnUserEarnedRewardCallback =
+ void Function(AdWithoutView ad, RewardItem reward);
/// The callback type to handle an error loading an [Ad].
typedef AdLoadErrorCallback = void Function(Ad ad, LoadAdError error);
/// The callback type for when an ad receives revenue value.
-typedef OnPaidEventCallback = void Function(
- Ad ad, double valueMicros, PrecisionType precision, String currencyCode);
+typedef OnPaidEventCallback =
+ void Function(
+ Ad ad,
+ double valueMicros,
+ PrecisionType precision,
+ String currencyCode,
+ );
/// The callback type for when a fluid ad's height changes.
-typedef OnFluidAdHeightChangedListener = void Function(
- FluidAdManagerBannerAd ad, double height);
+typedef OnFluidAdHeightChangedListener =
+ void Function(FluidAdManagerBannerAd ad, double height);
/// Allowed constants for precision type in [OnPaidEventCallback].
enum PrecisionType {
@@ -52,7 +57,7 @@ enum PrecisionType {
publisherProvided,
/// The precise value paid for this ad.
- precise
+ precise,
}
/// Listener for app events.
@@ -131,15 +136,15 @@ class BannerAdListener extends AdWithViewListener {
OnPaidEventCallback? onPaidEvent,
AdEventCallback? onAdClicked,
}) : super(
- onAdLoaded: onAdLoaded,
- onAdFailedToLoad: onAdFailedToLoad,
- onAdOpened: onAdOpened,
- onAdClosed: onAdClosed,
- onAdWillDismissScreen: onAdWillDismissScreen,
- onAdImpression: onAdImpression,
- onPaidEvent: onPaidEvent,
- onAdClicked: onAdClicked,
- );
+ onAdLoaded: onAdLoaded,
+ onAdFailedToLoad: onAdFailedToLoad,
+ onAdOpened: onAdOpened,
+ onAdClosed: onAdClosed,
+ onAdWillDismissScreen: onAdWillDismissScreen,
+ onAdImpression: onAdImpression,
+ onPaidEvent: onPaidEvent,
+ onAdClicked: onAdClicked,
+ );
}
/// A listener for receiving notifications for the lifecycle of an [AdManagerBannerAd].
@@ -170,15 +175,15 @@ class AdManagerBannerAdListener extends BannerAdListener
this.onAppEvent,
AdEventCallback? onAdClicked,
}) : super(
- onAdLoaded: onAdLoaded,
- onAdFailedToLoad: onAdFailedToLoad,
- onAdOpened: onAdOpened,
- onAdWillDismissScreen: onAdWillDismissScreen,
- onAdClosed: onAdClosed,
- onAdImpression: onAdImpression,
- onPaidEvent: onPaidEvent,
- onAdClicked: onAdClicked,
- );
+ onAdLoaded: onAdLoaded,
+ onAdFailedToLoad: onAdFailedToLoad,
+ onAdOpened: onAdOpened,
+ onAdWillDismissScreen: onAdWillDismissScreen,
+ onAdClosed: onAdClosed,
+ onAdImpression: onAdImpression,
+ onPaidEvent: onPaidEvent,
+ onAdClicked: onAdClicked,
+ );
/// Called when an app event is received.
@override
@@ -211,14 +216,15 @@ class NativeAdListener extends AdWithViewListener {
OnPaidEventCallback? onPaidEvent,
AdEventCallback? onAdClicked,
}) : super(
- onAdLoaded: onAdLoaded,
- onAdFailedToLoad: onAdFailedToLoad,
- onAdOpened: onAdOpened,
- onAdWillDismissScreen: onAdWillDismissScreen,
- onAdClosed: onAdClosed,
- onAdImpression: onAdImpression,
- onPaidEvent: onPaidEvent,
- onAdClicked: onAdClicked);
+ onAdLoaded: onAdLoaded,
+ onAdFailedToLoad: onAdFailedToLoad,
+ onAdOpened: onAdOpened,
+ onAdWillDismissScreen: onAdWillDismissScreen,
+ onAdClosed: onAdClosed,
+ onAdImpression: onAdImpression,
+ onPaidEvent: onPaidEvent,
+ onAdClicked: onAdClicked,
+ );
}
/// Callback events for for full screen ads, such as Rewarded and Interstitial.
diff --git a/packages/google_mobile_ads/lib/src/app_background_event_notifier.dart b/packages/google_mobile_ads/lib/src/app_background_event_notifier.dart
index 5fb61ed58..8c0d1e280 100644
--- a/packages/google_mobile_ads/lib/src/app_background_event_notifier.dart
+++ b/packages/google_mobile_ads/lib/src/app_background_event_notifier.dart
@@ -23,7 +23,7 @@ enum AppState {
background,
/// App is foregrounded.
- foreground
+ foreground,
}
/// Notifies changes in app foreground/background.
@@ -46,8 +46,10 @@ class AppStateEventNotifier {
/// Call [startListening] before subscribing to this stream to
/// start listening to background/foreground events on the platform side.
static Stream get appStateStream =>
- _eventChannel.receiveBroadcastStream().map((event) =>
- event == 'foreground' ? AppState.foreground : AppState.background);
+ _eventChannel.receiveBroadcastStream().map(
+ (event) =>
+ event == 'foreground' ? AppState.foreground : AppState.background,
+ );
/// Start listening to background/foreground events.
static Future startListening() async {
diff --git a/packages/google_mobile_ads/lib/src/mobile_ads.dart b/packages/google_mobile_ads/lib/src/mobile_ads.dart
index ac6ab1eac..ab6facb40 100644
--- a/packages/google_mobile_ads/lib/src/mobile_ads.dart
+++ b/packages/google_mobile_ads/lib/src/mobile_ads.dart
@@ -63,7 +63,8 @@ class MobileAds {
/// Update the [RequestConfiguration] to apply for future ad requests.
Future updateRequestConfiguration(
- RequestConfiguration requestConfiguration) {
+ RequestConfiguration requestConfiguration,
+ ) {
return instanceManager.updateRequestConfiguration(requestConfiguration);
}
@@ -157,9 +158,9 @@ class InitializationStatus {
///
/// Returned when calling [MobileAds.initialize];
InitializationStatus(Map adapterStatuses)
- : adapterStatuses = Map.unmodifiable(
- adapterStatuses,
- );
+ : adapterStatuses = Map.unmodifiable(
+ adapterStatuses,
+ );
/// Initialization status of each known ad network, keyed by its adapter's class name.
final Map adapterStatuses;
diff --git a/packages/google_mobile_ads/lib/src/nativetemplates/native_template_font_style.dart b/packages/google_mobile_ads/lib/src/nativetemplates/native_template_font_style.dart
index d7f9b81c8..451362ffd 100644
--- a/packages/google_mobile_ads/lib/src/nativetemplates/native_template_font_style.dart
+++ b/packages/google_mobile_ads/lib/src/nativetemplates/native_template_font_style.dart
@@ -24,5 +24,5 @@ enum NativeTemplateFontStyle {
italic,
/// Monospace
- monospace
+ monospace,
}
diff --git a/packages/google_mobile_ads/lib/src/nativetemplates/native_template_style.dart b/packages/google_mobile_ads/lib/src/nativetemplates/native_template_style.dart
index 0e800c450..8d6873ee8 100644
--- a/packages/google_mobile_ads/lib/src/nativetemplates/native_template_style.dart
+++ b/packages/google_mobile_ads/lib/src/nativetemplates/native_template_style.dart
@@ -74,12 +74,12 @@ class NativeTemplateStyle {
@override
int get hashCode => Object.hashAll([
- templateType,
- callToActionTextStyle,
- primaryTextStyle,
- secondaryTextStyle,
- tertiaryTextStyle,
- mainBackgroundColor,
- cornerRadius
- ]);
+ templateType,
+ callToActionTextStyle,
+ primaryTextStyle,
+ secondaryTextStyle,
+ tertiaryTextStyle,
+ mainBackgroundColor,
+ cornerRadius,
+ ]);
}
diff --git a/packages/google_mobile_ads/lib/src/nativetemplates/template_type.dart b/packages/google_mobile_ads/lib/src/nativetemplates/template_type.dart
index 48ba90c50..86b63c5b9 100644
--- a/packages/google_mobile_ads/lib/src/nativetemplates/template_type.dart
+++ b/packages/google_mobile_ads/lib/src/nativetemplates/template_type.dart
@@ -18,5 +18,5 @@ enum TemplateType {
small,
/// Medium layout
- medium
+ medium,
}
diff --git a/packages/google_mobile_ads/lib/src/request_configuration.dart b/packages/google_mobile_ads/lib/src/request_configuration.dart
index e027b5c1a..47491c7a2 100644
--- a/packages/google_mobile_ads/lib/src/request_configuration.dart
+++ b/packages/google_mobile_ads/lib/src/request_configuration.dart
@@ -30,11 +30,12 @@ class RequestConfiguration {
final List? testDeviceIds;
/// Creates a [RequestConfiguration].
- RequestConfiguration(
- {this.maxAdContentRating,
- this.tagForChildDirectedTreatment,
- this.tagForUnderAgeOfConsent,
- this.testDeviceIds});
+ RequestConfiguration({
+ this.maxAdContentRating,
+ this.tagForChildDirectedTreatment,
+ this.tagForUnderAgeOfConsent,
+ this.testDeviceIds,
+ });
}
/// Values for [RequestConfiguration.maxAdContentRating].
diff --git a/packages/google_mobile_ads/lib/src/ump/consent_form.dart b/packages/google_mobile_ads/lib/src/ump/consent_form.dart
index 62e0514f4..0cd3dd01f 100644
--- a/packages/google_mobile_ads/lib/src/ump/consent_form.dart
+++ b/packages/google_mobile_ads/lib/src/ump/consent_form.dart
@@ -21,8 +21,8 @@ import 'user_messaging_channel.dart';
typedef OnConsentFormDismissedListener = void Function(FormError? formError);
/// Callback to be invoked when a consent form loads successfully
-typedef OnConsentFormLoadSuccessListener = void Function(
- ConsentForm consentForm);
+typedef OnConsentFormLoadSuccessListener =
+ void Function(ConsentForm consentForm);
/// Callback to be invoked when a consent form failed to load.
typedef OnConsentFormLoadFailureListener = void Function(FormError formError);
@@ -34,9 +34,11 @@ abstract class ConsentForm {
/// Presents a privacy options form.
static Future showPrivacyOptionsForm(
- OnConsentFormDismissedListener onConsentFormDismissedListener) async {
+ OnConsentFormDismissedListener onConsentFormDismissedListener,
+ ) async {
onConsentFormDismissedListener(
- await UserMessagingChannel.instance.showPrivacyOptionsForm());
+ await UserMessagingChannel.instance.showPrivacyOptionsForm(),
+ );
}
/// Free platform resources associated with this object.
@@ -48,16 +50,22 @@ abstract class ConsentForm {
///
/// Check that [ConsentInformation.isConsentFormAvailable()] returns true
/// prior to calling this method.
- static void loadConsentForm(OnConsentFormLoadSuccessListener successListener,
- OnConsentFormLoadFailureListener failureListener) {
- UserMessagingChannel.instance
- .loadConsentForm(successListener, failureListener);
+ static void loadConsentForm(
+ OnConsentFormLoadSuccessListener successListener,
+ OnConsentFormLoadFailureListener failureListener,
+ ) {
+ UserMessagingChannel.instance.loadConsentForm(
+ successListener,
+ failureListener,
+ );
}
/// Loads a consent form and immediately shows it.
static Future loadAndShowConsentFormIfRequired(
- OnConsentFormDismissedListener onConsentFormDismissedListener) async {
+ OnConsentFormDismissedListener onConsentFormDismissedListener,
+ ) async {
onConsentFormDismissedListener(
- await UserMessagingChannel.instance.loadAndShowConsentFormIfRequired());
+ await UserMessagingChannel.instance.loadAndShowConsentFormIfRequired(),
+ );
}
}
diff --git a/packages/google_mobile_ads/lib/src/ump/consent_information.dart b/packages/google_mobile_ads/lib/src/ump/consent_information.dart
index c64f3bf16..5d265941d 100644
--- a/packages/google_mobile_ads/lib/src/ump/consent_information.dart
+++ b/packages/google_mobile_ads/lib/src/ump/consent_information.dart
@@ -42,9 +42,10 @@ enum ConsentStatus {
abstract class ConsentInformation {
/// Requests a consent information update.
void requestConsentInfoUpdate(
- ConsentRequestParameters params,
- OnConsentInfoUpdateSuccessListener successListener,
- OnConsentInfoUpdateFailureListener failureListener);
+ ConsentRequestParameters params,
+ OnConsentInfoUpdateSuccessListener successListener,
+ OnConsentInfoUpdateFailureListener failureListener,
+ );
/// Returns true if a ConsentForm is available, false otherwise.
Future isConsentFormAvailable();
@@ -80,5 +81,5 @@ enum PrivacyOptionsRequirementStatus {
required,
/// Privacy options requirement status is unknown.
- unknown;
+ unknown,
}
diff --git a/packages/google_mobile_ads/lib/src/ump/consent_information_impl.dart b/packages/google_mobile_ads/lib/src/ump/consent_information_impl.dart
index 5fb15322e..c2a4fe811 100644
--- a/packages/google_mobile_ads/lib/src/ump/consent_information_impl.dart
+++ b/packages/google_mobile_ads/lib/src/ump/consent_information_impl.dart
@@ -23,11 +23,15 @@ class ConsentInformationImpl extends ConsentInformation {
@override
void requestConsentInfoUpdate(
- ConsentRequestParameters params,
- OnConsentInfoUpdateSuccessListener successListener,
- OnConsentInfoUpdateFailureListener failureListener) {
- UserMessagingChannel.instance
- .requestConsentInfoUpdate(params, successListener, failureListener);
+ ConsentRequestParameters params,
+ OnConsentInfoUpdateSuccessListener successListener,
+ OnConsentInfoUpdateFailureListener failureListener,
+ ) {
+ UserMessagingChannel.instance.requestConsentInfoUpdate(
+ params,
+ successListener,
+ failureListener,
+ );
}
@override
diff --git a/packages/google_mobile_ads/lib/src/ump/consent_request_parameters.dart b/packages/google_mobile_ads/lib/src/ump/consent_request_parameters.dart
index 7419d211a..f9f031a6a 100644
--- a/packages/google_mobile_ads/lib/src/ump/consent_request_parameters.dart
+++ b/packages/google_mobile_ads/lib/src/ump/consent_request_parameters.dart
@@ -17,8 +17,10 @@ import 'package:flutter/foundation.dart';
/// Parameters sent on updating user consent info.
class ConsentRequestParameters {
/// Construct a [ConsentRequestParameters].
- ConsentRequestParameters(
- {this.tagForUnderAgeOfConsent, this.consentDebugSettings});
+ ConsentRequestParameters({
+ this.tagForUnderAgeOfConsent,
+ this.consentDebugSettings,
+ });
/// Tag for underage of consent.
///
@@ -80,5 +82,5 @@ enum DebugGeography {
debugGeographyRegulatedUsState,
/// Geography appears as in a region with no regulation in force.
- debugGeographyOther
+ debugGeographyOther,
}
diff --git a/packages/google_mobile_ads/lib/src/ump/user_messaging_channel.dart b/packages/google_mobile_ads/lib/src/ump/user_messaging_channel.dart
index d795b83f6..9a64e2f1d 100644
--- a/packages/google_mobile_ads/lib/src/ump/user_messaging_channel.dart
+++ b/packages/google_mobile_ads/lib/src/ump/user_messaging_channel.dart
@@ -29,8 +29,12 @@ class UserMessagingChannel {
UserMessagingChannel(MethodChannel channel) : _methodChannel = channel;
/// The shared [UserMessagingChannel] instance.
- static UserMessagingChannel instance = UserMessagingChannel(MethodChannel(
- _methodChannelName, StandardMethodCodec(UserMessagingCodec())));
+ static UserMessagingChannel instance = UserMessagingChannel(
+ MethodChannel(
+ _methodChannelName,
+ StandardMethodCodec(UserMessagingCodec()),
+ ),
+ );
final MethodChannel _methodChannel;
@@ -39,15 +43,14 @@ class UserMessagingChannel {
/// Invokes [successListener] or [failureListener] depending on if there was
/// an error.
void requestConsentInfoUpdate(
- ConsentRequestParameters params,
- OnConsentInfoUpdateSuccessListener successListener,
- OnConsentInfoUpdateFailureListener failureListener) async {
+ ConsentRequestParameters params,
+ OnConsentInfoUpdateSuccessListener successListener,
+ OnConsentInfoUpdateFailureListener failureListener,
+ ) async {
try {
await _methodChannel.invokeMethod(
'ConsentInformation#requestConsentInfoUpdate',
- {
- 'params': params,
- },
+ {'params': params},
);
successListener();
} on PlatformException catch (e) {
@@ -57,14 +60,16 @@ class UserMessagingChannel {
/// Returns a future indicating whether a consent form is available.
Future isConsentFormAvailable() async {
- return (await _methodChannel
- .invokeMethod('ConsentInformation#isConsentFormAvailable'))!;
+ return (await _methodChannel.invokeMethod(
+ 'ConsentInformation#isConsentFormAvailable',
+ ))!;
}
/// Gets the consent status.
Future getConsentStatus() async {
- int consentStatus = (await _methodChannel
- .invokeMethod('ConsentInformation#getConsentStatus'))!;
+ int consentStatus = (await _methodChannel.invokeMethod(
+ 'ConsentInformation#getConsentStatus',
+ ))!;
if (defaultTargetPlatform == TargetPlatform.iOS) {
switch (consentStatus) {
@@ -104,15 +109,17 @@ class UserMessagingChannel {
/// Returns indicating whether it is ok to request ads.
Future canRequestAds() async {
- return (await _methodChannel
- .invokeMethod('ConsentInformation#canRequestAds'))!;
+ return (await _methodChannel.invokeMethod(
+ 'ConsentInformation#canRequestAds',
+ ))!;
}
/// Indicates the privacy options requirement status as a [PrivacyOptionsRequirementStatus].
Future
- getPrivacyOptionsRequirementStatus() async {
+ getPrivacyOptionsRequirementStatus() async {
int? privacyOptionsStatusInt = (await _methodChannel.invokeMethod(
- 'ConsentInformation#getPrivacyOptionsRequirementStatus'));
+ 'ConsentInformation#getPrivacyOptionsRequirementStatus',
+ ));
switch (privacyOptionsStatusInt) {
case 0:
return PrivacyOptionsRequirementStatus.notRequired;
@@ -124,11 +131,14 @@ class UserMessagingChannel {
}
/// Loads a consent form and calls the corresponding listener.
- void loadConsentForm(OnConsentFormLoadSuccessListener successListener,
- OnConsentFormLoadFailureListener failureListener) async {
+ void loadConsentForm(
+ OnConsentFormLoadSuccessListener successListener,
+ OnConsentFormLoadFailureListener failureListener,
+ ) async {
try {
- ConsentForm form = (await _methodChannel
- .invokeMethod('UserMessagingPlatform#loadConsentForm'))!;
+ ConsentForm form = (await _methodChannel.invokeMethod(
+ 'UserMessagingPlatform#loadConsentForm',
+ ))!;
successListener(form);
} on PlatformException catch (e) {
failureListener(_formErrorFromPlatformException(e));
@@ -139,21 +149,22 @@ class UserMessagingChannel {
Future loadAndShowConsentFormIfRequired() async {
try {
return await _methodChannel.invokeMethod(
- 'UserMessagingPlatform#loadAndShowConsentFormIfRequired');
+ 'UserMessagingPlatform#loadAndShowConsentFormIfRequired',
+ );
} on PlatformException catch (e) {
return _formErrorFromPlatformException(e);
}
}
/// Show the consent form.
- void show(ConsentForm consentForm,
- OnConsentFormDismissedListener onConsentFormDismissedListener) async {
+ void show(
+ ConsentForm consentForm,
+ OnConsentFormDismissedListener onConsentFormDismissedListener,
+ ) async {
try {
await _methodChannel.invokeMethod(
'ConsentForm#show',
- {
- 'consentForm': consentForm,
- },
+ {'consentForm': consentForm},
);
onConsentFormDismissedListener(null);
} on PlatformException catch (e) {
@@ -165,7 +176,8 @@ class UserMessagingChannel {
Future showPrivacyOptionsForm() async {
try {
return await _methodChannel.invokeMethod(
- 'UserMessagingPlatform#showPrivacyOptionsForm');
+ 'UserMessagingPlatform#showPrivacyOptionsForm',
+ );
} on PlatformException catch (e) {
return _formErrorFromPlatformException(e);
}
@@ -173,16 +185,16 @@ class UserMessagingChannel {
FormError _formErrorFromPlatformException(PlatformException e) {
return FormError(
- errorCode: int.tryParse(e.code) ?? -1, message: e.message ?? '');
+ errorCode: int.tryParse(e.code) ?? -1,
+ message: e.message ?? '',
+ );
}
/// Free platform resources associated with the [ConsentForm].
Future disposeConsentForm(ConsentForm consentForm) {
return _methodChannel.invokeMethod