fix(bluetooth_controller): cache for dispose
This commit is contained in:
@ -35,6 +35,7 @@ class BootloaderRecoveryUpdatePage extends ConsumerStatefulWidget {
|
|||||||
class _BootloaderRecoveryUpdatePageState
|
class _BootloaderRecoveryUpdatePageState
|
||||||
extends ConsumerState<BootloaderRecoveryUpdatePage> {
|
extends ConsumerState<BootloaderRecoveryUpdatePage> {
|
||||||
FirmwareUpdateService? _firmwareUpdateService;
|
FirmwareUpdateService? _firmwareUpdateService;
|
||||||
|
BluetoothController? _bluetooth;
|
||||||
StreamSubscription<DfuUpdateProgress>? _firmwareProgressSubscription;
|
StreamSubscription<DfuUpdateProgress>? _firmwareProgressSubscription;
|
||||||
DfuUpdateProgress _dfuProgress = const DfuUpdateProgress(
|
DfuUpdateProgress _dfuProgress = const DfuUpdateProgress(
|
||||||
state: DfuUpdateState.idle,
|
state: DfuUpdateState.idle,
|
||||||
@ -60,7 +61,7 @@ class _BootloaderRecoveryUpdatePageState
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
final service = _firmwareUpdateService;
|
final service = _firmwareUpdateService;
|
||||||
final bluetooth = ref.read(bluetoothProvider).valueOrNull;
|
final bluetooth = _bluetooth;
|
||||||
_firmwareUpdateService = null;
|
_firmwareUpdateService = null;
|
||||||
unawaited(_firmwareProgressSubscription?.cancel());
|
unawaited(_firmwareProgressSubscription?.cancel());
|
||||||
unawaited(() async {
|
unawaited(() async {
|
||||||
@ -105,6 +106,7 @@ class _BootloaderRecoveryUpdatePageState
|
|||||||
if (bluetooth == null) {
|
if (bluetooth == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
_bluetooth = bluetooth;
|
||||||
|
|
||||||
final service = FirmwareUpdateService(
|
final service = FirmwareUpdateService(
|
||||||
verifyAfterFinish: false,
|
verifyAfterFinish: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user