Skip to content

Commit 15947a0

Browse files
committed
Fix 'LateInitializationError' exception.
1 parent 192c57f commit 15947a0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

example/lib/src/ble/ble_device_connector.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class BleDeviceConnector extends ReactiveState<ConnectionStateUpdate> {
1919
final _deviceConnectionController = StreamController<ConnectionStateUpdate>();
2020

2121
// ignore: cancel_subscriptions
22-
late StreamSubscription<ConnectionStateUpdate> _connection;
22+
StreamSubscription<ConnectionStateUpdate>? _connection;
2323

2424
Future<void> connect(String deviceId) async {
2525
_logMessage('Start connecting to $deviceId');
@@ -37,7 +37,7 @@ class BleDeviceConnector extends ReactiveState<ConnectionStateUpdate> {
3737
Future<void> disconnect(String deviceId) async {
3838
try {
3939
_logMessage('disconnecting to device: $deviceId');
40-
await _connection.cancel();
40+
await _connection?.cancel();
4141
} on Exception catch (e, _) {
4242
_logMessage("Error disconnecting from a device: $e");
4343
} finally {

0 commit comments

Comments
 (0)