Reputation: 13
device.connect(autoConnect: false).timeout(Duration(seconds: 5),
onTimeout: () {
print("flutter ble time out");
})
I want to stop this function befor the time out,how to do?
Upvotes: 1
Views: 1826
Reputation: 34170
Timeout will happen after 5 seconds, so before that, if we want to disconnect the connection, use the below code, call it from any button press, see it should work.
device.disconnect();
Also, if you want to stop search use
FlutterBlue.instance.stopScan()
Upvotes: 1