disconnect method

void disconnect()

Disconnects from the currently connected device.

This method checks if there is an active scan result representing a connected device. If a device is currently connected, it will be disconnected without queuing the disconnection request.

Note: Ensure that this method is called only when a device is connected. If there is no active connection, this method will not perform any action.

Implementation

void disconnect() {
  if (_currentScanResult != null) {
    _currentScanResult?.device.disconnect(queue: false);
  }
}