fix: lifecycle

This commit is contained in:
2026-05-05 22:01:22 +02:00
parent 0da0905697
commit 30b25784c1
3 changed files with 53 additions and 16 deletions

View File

@ -66,15 +66,21 @@ class _BootloaderRecoveryUpdatePageState
unawaited(_firmwareProgressSubscription?.cancel());
unawaited(() async {
await service?.dispose();
await _disconnectBootloaderIfStillConnected(bluetooth: bluetooth);
await _disconnectBootloaderIfStillConnected(
bluetooth: bluetooth,
allowRefRead: false,
);
}());
super.dispose();
}
Future<void> _disconnectBootloaderIfStillConnected({
BluetoothController? bluetooth,
bool allowRefRead = true,
}) async {
bluetooth ??= ref.read(bluetoothProvider).valueOrNull;
if (bluetooth == null && allowRefRead) {
bluetooth = ref.read(bluetoothProvider).valueOrNull;
}
if (bluetooth == null) {
return;
}