@@ -56,26 +56,29 @@ class InAppUpdate {
56
56
/// Returns [AppUpdateInfo] , which can be used to decide if
57
57
/// [startFlexibleUpdate] or [performImmediateUpdate] should be called.
58
58
static Future <AppUpdateInfo > checkForUpdate () async {
59
- final result = await _channel.invokeMethod ('checkForUpdate' );
60
-
61
- return AppUpdateInfo (
62
- updateAvailability: UpdateAvailability .values.firstWhere (
63
- (element) => element.value == result['updateAvailability' ]),
64
- immediateUpdateAllowed: result['immediateAllowed' ],
65
- immediateAllowedPreconditions: result['immediateAllowedPreconditions' ]
66
- ? .map <int >((e) => e as int )
67
- .toList (),
68
- flexibleUpdateAllowed: result['flexibleAllowed' ],
69
- flexibleAllowedPreconditions: result['flexibleAllowedPreconditions' ]
70
- ? .map <int >((e) => e as int )
71
- .toList (),
72
- availableVersionCode: result['availableVersionCode' ],
73
- installStatus: InstallStatus .values
74
- .firstWhere ((element) => element.value == result['installStatus' ]),
75
- packageName: result['packageName' ],
76
- clientVersionStalenessDays: result['clientVersionStalenessDays' ],
77
- updatePriority: result['updatePriority' ],
78
- );
59
+ try {
60
+ final result = await _channel.invokeMethod ('checkForUpdate' );
61
+ return AppUpdateInfo (
62
+ updateAvailability: UpdateAvailability .values.firstWhere (
63
+ (element) => element.value == result['updateAvailability' ]),
64
+ immediateUpdateAllowed: result['immediateAllowed' ],
65
+ immediateAllowedPreconditions: result['immediateAllowedPreconditions' ]
66
+ ? .map <int >((e) => e as int )
67
+ .toList (),
68
+ flexibleUpdateAllowed: result['flexibleAllowed' ],
69
+ flexibleAllowedPreconditions: result['flexibleAllowedPreconditions' ]
70
+ ? .map <int >((e) => e as int )
71
+ .toList (),
72
+ availableVersionCode: result['availableVersionCode' ],
73
+ installStatus: InstallStatus .values
74
+ .firstWhere ((element) => element.value == result['installStatus' ]),
75
+ packageName: result['packageName' ],
76
+ clientVersionStalenessDays: result['clientVersionStalenessDays' ],
77
+ updatePriority: result['updatePriority' ],
78
+ );
79
+ } on PlatformException catch (e) {
80
+ throw e;
81
+ }
79
82
}
80
83
81
84
/// Performs an immediate update that is entirely handled by the Play API.
0 commit comments