disconnect method

Future<ConnectionStatus> disconnect({
  1. Duration timeout = const Duration(seconds: 5),
})

To stop communication between bluetooth device and application

Implementation

Future<ConnectionStatus> disconnect({
  Duration timeout = const Duration(seconds: 5),
}) async {
  if (Platform.isAndroid) {
    if (await _bluetoothAndroid?.isConnected ?? false) {
      await _bluetoothAndroid?.disconnect();
    }
    _isConnected = false;
  } else if (Platform.isIOS) {
    await _bluetoothDeviceIOS?.disconnect();
    _isConnected = false;
  }

  return ConnectionStatus.disconnect;
}