Skip to content

Commit b0983a8

Browse files
committed
Cancel timer when connect throws
1 parent d7517ee commit b0983a8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/src/bluetooth_device.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ class BluetoothDevice {
3434
});
3535
}
3636

37+
try {
38+
3739
await FlutterBlue.instance._channel
3840
.invokeMethod('connect', request.writeToBuffer());
41+
} catch (e) {
42+
timer?.cancel();
43+
rethrow;
44+
}
3945

4046
await state.firstWhere((s) => s == BluetoothDeviceState.connected);
4147

0 commit comments

Comments
 (0)