fix(bluetooth_controller): cache for dispose
This commit is contained in:
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user