disconnect static method

Future<void> disconnect(
  1. dynamic address
)

disconnect will update a Stream of boolean getConnectionStream and also ignore if that device is already disconnected

Implementation

static Future<void> disconnect(address) async {
  try {
    await _channel.invokeMethod("disconnect", args: {
      "device": WinHelper.getDeviceFromAddress(address),
    });
    _connectionStreamController.add({
      "device": address,
      "connected": false,
    });
    WinHelper.deviceMap[address] = null;
  } catch (e) {
    if (e.toString().contains("not found")) {
      // ignore for now
    } else {
      rethrow;
    }
  }
}