disconnect method

Future<bool> disconnect()

Disconnects from a device

Implementation

Future<bool> disconnect() async {
  if (_connectionState != BluetoothConnectionState.connected) {
    return false;
  }

  _updateConnectionState(BluetoothConnectionState.disconnecting);

  try {
    return await _channel.invokeMethod('disconnect');
  } catch (e) {
    _updateConnectionState(BluetoothConnectionState.error);
    return false;
  }
}