陈绪华
陈绪华

Reputation: 13

flutter_blue how to stop connect()?

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

Answers (1)

Jitesh Mohite
Jitesh Mohite

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

Related Questions