From 71fec05a135c471548e0cf74e754f49dbc014d9b Mon Sep 17 00:00:00 2001 From: "Md.Masud Parvez" Date: Fri, 3 Jun 2022 03:10:31 +0600 Subject: [PATCH] flutter 3.0 support added (#295) --- android/build.gradle | 4 +-- .../shatsy/admobflutter/AdmobBannerFactory.kt | 6 ++-- .../shatsy/admobflutter/AdmobInterstitial.kt | 2 +- .../com/shatsy/admobflutter/AdmobReward.kt | 2 +- example/android/app/build.gradle | 6 ++-- .../android/app/src/main/AndroidManifest.xml | 3 +- example/android/build.gradle | 2 +- example/lib/extensions.dart | 2 +- example/pubspec.lock | 28 +++++++++---------- pubspec.lock | 20 ++++++------- pubspec.yaml | 2 +- 11 files changed, 39 insertions(+), 38 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 62bd05d..0837e7f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,7 +2,7 @@ group 'com.shatsy.admobflutter' version '1.0.0-beta.3' buildscript { - ext.kotlin_version = '1.3.72' + ext.kotlin_version = '1.6.10' repositories { google() jcenter() @@ -25,7 +25,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 28 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/android/src/main/kotlin/com/shatsy/admobflutter/AdmobBannerFactory.kt b/android/src/main/kotlin/com/shatsy/admobflutter/AdmobBannerFactory.kt index b65b518..07a21e2 100644 --- a/android/src/main/kotlin/com/shatsy/admobflutter/AdmobBannerFactory.kt +++ b/android/src/main/kotlin/com/shatsy/admobflutter/AdmobBannerFactory.kt @@ -6,8 +6,8 @@ import io.flutter.plugin.common.StandardMessageCodec import io.flutter.plugin.platform.PlatformView import io.flutter.plugin.platform.PlatformViewFactory -class AdmobBannerFactory(private val messenger: BinaryMessenger): PlatformViewFactory(StandardMessageCodec.INSTANCE) { - override fun create(context: Context, viewId: Int, args: Any?): PlatformView { - return AdmobBanner(context, messenger, viewId, args as HashMap<*, *>) + class AdmobBannerFactory(private val messenger: BinaryMessenger): PlatformViewFactory(StandardMessageCodec.INSTANCE) { + override fun create(context: Context?, viewId: Int, args: Any?): PlatformView { + return AdmobBanner(context!!, messenger, viewId, args as HashMap<*, *>) } } \ No newline at end of file diff --git a/android/src/main/kotlin/com/shatsy/admobflutter/AdmobInterstitial.kt b/android/src/main/kotlin/com/shatsy/admobflutter/AdmobInterstitial.kt index 4549d9c..2476aa0 100644 --- a/android/src/main/kotlin/com/shatsy/admobflutter/AdmobInterstitial.kt +++ b/android/src/main/kotlin/com/shatsy/admobflutter/AdmobInterstitial.kt @@ -60,7 +60,7 @@ class AdmobInterstitial(private val flutterPluginBinding: FlutterPlugin.FlutterP if (allAds[id]!!.isLoaded) { allAds[id]!!.show() - } else result.error(null, null, null) + } else result.error("2", null, null) } "dispose" -> { val id = call.argument("id") diff --git a/android/src/main/kotlin/com/shatsy/admobflutter/AdmobReward.kt b/android/src/main/kotlin/com/shatsy/admobflutter/AdmobReward.kt index 0fbeef1..a04a04f 100644 --- a/android/src/main/kotlin/com/shatsy/admobflutter/AdmobReward.kt +++ b/android/src/main/kotlin/com/shatsy/admobflutter/AdmobReward.kt @@ -63,7 +63,7 @@ class AdmobReward(private val flutterPluginBinding: FlutterPlugin.FlutterPluginB if (allAds[id]!!.isLoaded) { allAds[id]!!.show() - } else result.error(null, null, null) + } else result.error("2", null, null) } "dispose" -> { val id = call.argument("id") diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 9a4f163..7ecc335 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -38,8 +38,8 @@ android { defaultConfig { applicationId "com.shatsy.admobflutterexample" - minSdkVersion 16 - targetSdkVersion 28 + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 3b4a642..0653b2d 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -20,7 +20,8 @@ android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~3347511713" /> - + diff --git a/example/android/build.gradle b/example/android/build.gradle index 7536fb8..63d56d4 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.3.40' + ext.kotlin_version = '1.6.10' repositories { google() jcenter() diff --git a/example/lib/extensions.dart b/example/lib/extensions.dart index f214024..40e174e 100644 --- a/example/lib/extensions.dart +++ b/example/lib/extensions.dart @@ -63,7 +63,7 @@ class TopBannerAdAppRecipe extends StatelessWidget { return Directionality( textDirection: TextDirection.rtl, child: MediaQuery( - data: MediaQueryData.fromWindow(WidgetsBinding.instance!.window), + data: MediaQueryData.fromWindow(WidgetsBinding.instance.window), child: Container( color: Colors.blueGrey, child: Column(children: [ diff --git a/example/pubspec.lock b/example/pubspec.lock index 221e8d6..8c7c20d 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -49,7 +49,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: @@ -63,7 +63,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -81,6 +81,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" meta: dependency: transitive description: @@ -94,7 +101,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" pedantic: dependency: "direct dev" description: @@ -113,7 +120,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -148,21 +155,14 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.9" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.17.1 <3.0.0" flutter: ">=2.0.0" diff --git a/pubspec.lock b/pubspec.lock index a09752e..abab220 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -14,12 +14,19 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" meta: dependency: transitive description: @@ -39,20 +46,13 @@ packages: description: flutter source: sdk version: "0.0.99" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.17.1 <3.0.0" flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 3c68389..804ee31 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 2.0.0 homepage: https://github.com/kmcgill88/admob_flutter environment: - sdk: '>=2.12.0 <3.0.0' + sdk: ">=2.17.1 <3.0.0" flutter: ">=2.0.0" dependencies: