Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
Expand Down
43 changes: 23 additions & 20 deletions lib/in_app_update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,29 @@ class InAppUpdate {
/// Returns [AppUpdateInfo], which can be used to decide if
/// [startFlexibleUpdate] or [performImmediateUpdate] should be called.
static Future<AppUpdateInfo> checkForUpdate() async {
final result = await _channel.invokeMethod('checkForUpdate');

return AppUpdateInfo(
updateAvailability: UpdateAvailability.values.firstWhere(
(element) => element.value == result['updateAvailability']),
immediateUpdateAllowed: result['immediateAllowed'],
immediateAllowedPreconditions: result['immediateAllowedPreconditions']
?.map<int>((e) => e as int)
.toList(),
flexibleUpdateAllowed: result['flexibleAllowed'],
flexibleAllowedPreconditions: result['flexibleAllowedPreconditions']
?.map<int>((e) => e as int)
.toList(),
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'],
immediateAllowedPreconditions: result['immediateAllowedPreconditions']
?.map<int>((e) => e as int)
.toList(),
flexibleUpdateAllowed: result['flexibleAllowed'],
flexibleAllowedPreconditions: result['flexibleAllowedPreconditions']
?.map<int>((e) => e as int)
.toList(),
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;
}
}

static Stream<InstallStatus> get installUpdateListener {
Expand Down