Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/src/bluetooth_device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BluetoothDevice {
Future<void> connect({
Duration? timeout,
bool autoConnect = true,
}) async {
}) {
final completer = Completer<void>();
var request = protos.ConnectRequest.create()
..remoteId = id.toString()
Expand All @@ -36,14 +36,14 @@ class BluetoothDevice {
});
}

await FlutterBlue.instance._channel
.invokeMethod('connect', request.writeToBuffer());

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

timer?.cancel();

completer.complete();
FlutterBlue.instance._channel
.invokeMethod('connect', request.writeToBuffer())
.then((_) {
state.firstWhere((s) => s == BluetoothDeviceState.connected).then((_) {
timer?.cancel();
completer.complete();
});
});

return completer.future;
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_blue
description:
Flutter plugin for connecting and communicating with Bluetooth Low Energy devices,
on Android and iOS
version: 0.11.0
version: 0.12.0
homepage: https://github.com/pauldemarco/flutter_blue

environment:
Expand Down