flutter_blue how to stop connect()?

846

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()
Share:
846
陈绪华
Author by

陈绪华

Updated on December 28, 2022

Comments

  • 陈绪华
    陈绪华 over 1 year
    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?

  • 陈绪华
    陈绪华 about 3 years
    thanks for you answer,this function is disconnect bluetooth in my understanding,I want to stop connecting,will it work?
  • Jitesh Mohite
    Jitesh Mohite about 3 years
    yes it should, also if you want to stop search use FlutterBlue.instance.stopScan(),