startFlexibleUpdate method
Starts the FLEXIBLE update flow and reports state changes.
Implementation
Future<void> startFlexibleUpdate({InstallStateCallback? onState}) async {
final info = await _ensureInfo();
if (!info.isFlexibleAllowed) {
throw StateError('Flexible updates are not allowed for this app version');
}
_stateCallback = InstallStateUpdatedListenerProxy$InstallStateCallbackInterface.implement(
$InstallStateUpdatedListenerProxy$InstallStateCallbackInterface(
onStateUpdate$async: true,
onStateUpdate: (state) {
final snapshot = _mapInstallState(state);
state.release();
onState?.call(snapshot);
},
),
);
final proxy = InstallStateUpdatedListenerProxy(_stateCallback!);
_registerStateListener(proxy);
final task = _manager.startUpdateFlow(
_lastInfo!,
_requireActivity(),
AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE) //
.setAllowAssetPackDeletion(true)
.build(),
);
if (task == null) {
throw StateError('startUpdateFlow returned null');
}
await _awaitTask<jni.JInteger?, void>(task, op: 'startUpdateFlow');
}