From adb4b9dedf3b96de9fb445633aff1ef8b146ff9c Mon Sep 17 00:00:00 2001 From: Fabio Parra Date: Fri, 18 Nov 2022 13:06:24 -0500 Subject: [PATCH 1/2] Catch PlatformException on checkForUpdate method Android Studio and VS Code throws handled exceptions as uncaught when there is no an explicit Try Catch call in some cases. For example: https://github.com/flutter/flutter/issues/33427 --- lib/in_app_update.dart | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/in_app_update.dart b/lib/in_app_update.dart index b4e2ad6..96d092d 100644 --- a/lib/in_app_update.dart +++ b/lib/in_app_update.dart @@ -56,19 +56,23 @@ class InAppUpdate { /// Returns [AppUpdateInfo], which can be used to decide if /// [startFlexibleUpdate] or [performImmediateUpdate] should be called. static Future checkForUpdate() async { - final result = await _channel.invokeMethod('checkForUpdate'); - - return AppUpdateInfo( - updateAvailability: - UpdateAvailability.values.firstWhere((element) => element.value == result['updateAvailability']), - immediateUpdateAllowed: result['immediateAllowed'], - flexibleUpdateAllowed: result['flexibleAllowed'], - availableVersionCode: result['availableVersionCode'], - installStatus: InstallStatus.values.firstWhere((element) => element.value == result['installStatus']), - packageName: result['packageName'], - clientVersionStalenessDays: result['clientVersionStalenessDays'], - updatePriority: result['updatePriority'], - ); + try { + final result = await _channel.invokeMethod('checkForUpdate'); + + return AppUpdateInfo( + updateAvailability: + UpdateAvailability.values.firstWhere((element) => element.value == result['updateAvailability']), + immediateUpdateAllowed: result['immediateAllowed'], + flexibleUpdateAllowed: result['flexibleAllowed'], + availableVersionCode: result['availableVersionCode'], + installStatus: InstallStatus.values.firstWhere((element) => element.value == result['installStatus']), + packageName: result['packageName'], + clientVersionStalenessDays: result['clientVersionStalenessDays'], + updatePriority: result['updatePriority'], + ); + } on PlatformException catch (e) { + throw e; + } } /// Performs an immediate update that is entirely handled by the Play API. From 9c0335efe36700f6095157686d28067d674ba4b8 Mon Sep 17 00:00:00 2001 From: Mr John <38257989+MrJohnDev@users.noreply.github.com> Date: Mon, 23 Jan 2023 11:56:16 +0700 Subject: [PATCH 2/2] Kotlin Update --- android/build.gradle | 4 ++-- example/android/build.gradle | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index c57258e..7b1043a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,10 +2,10 @@ group 'de.ffuf.in_app_update' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.6.21' + ext.kotlin_version = '1.7.21' repositories { google() - jcenter() + mavenCentral() } dependencies { diff --git a/example/android/build.gradle b/example/android/build.gradle index 1f25ba9..1f0db81 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,8 +1,8 @@ buildscript { - ext.kotlin_version = '1.6.21' + ext.kotlin_version = '1.7.21' repositories { google() - jcenter() + mavenCentral() } dependencies {