disconnect method
Future<void>
disconnect(
{ - int timeout = 35,
})
Implementation
Future<void> disconnect({int timeout = 35}) async {
final Future<BleConnectionEvent> responseFuture = BlePlatform
.instance
.connectionState
.firstWhere(
(event) =>
event.remoteId == remoteId &&
event.connectionState == BleConnectionState.disconnected,
);
final bool changed = await BlePlatform.instance.disconnect(remoteId.str);
if (changed) {
await responseFuture.timeout(
Duration(seconds: timeout),
onTimeout: () {
throw BleException(
operation: 'disconnect',
message: 'Timed out after ${timeout}s',
);
},
);
}
}