fix(bluetooth_controller): cache for dispose

This commit is contained in:
2026-05-05 21:26:58 +02:00
parent 4fceb0c690
commit 0da0905697

View File

@ -35,6 +35,7 @@ class BootloaderRecoveryUpdatePage extends ConsumerStatefulWidget {
class _BootloaderRecoveryUpdatePageState
extends ConsumerState<BootloaderRecoveryUpdatePage> {
FirmwareUpdateService? _firmwareUpdateService;
BluetoothController? _bluetooth;
StreamSubscription<DfuUpdateProgress>? _firmwareProgressSubscription;
DfuUpdateProgress _dfuProgress = const DfuUpdateProgress(
state: DfuUpdateState.idle,
@ -60,7 +61,7 @@ class _BootloaderRecoveryUpdatePageState
@override
void dispose() {
final service = _firmwareUpdateService;
final bluetooth = ref.read(bluetoothProvider).valueOrNull;
final bluetooth = _bluetooth;
_firmwareUpdateService = null;
unawaited(_firmwareProgressSubscription?.cancel());
unawaited(() async {
@ -105,6 +106,7 @@ class _BootloaderRecoveryUpdatePageState
if (bluetooth == null) {
return null;
}
_bluetooth = bluetooth;
final service = FirmwareUpdateService(
verifyAfterFinish: false,