connectToServiceByNameWithChannel method

*[<Null safety>](https://dart.dev/null-safety)*

void connectToServiceByNameWithChannel (String? serviceName, Channel? channel)

Implementation

void connectToServiceByNameWithChannel(
    String? serviceName, Channel? channel) {
  if (serviceName == null) {
    throw Exception(
        'serviceName must not be null. Check the FIDL file for a missing '
        '[Discoverable]');
  }
  if (channel == null) {
    throw ArgumentError.notNull('channel');
  }

  if (_dirProxy.ctrl.isUnbound) {
    throw IncomingStateException(
        'The directory must be bound before trying to connect to a service. '
        'See [Incoming.request] for more information');
  }

  // connection flags for service: can read & write from target object.
  final OpenFlags _openFlags =
      OpenFlags.rightReadable | OpenFlags.rightWritable;
  // 0755
  const int _openMode = 0x1ED;

  _dirProxy.open(
      _openFlags, _openMode, serviceName, InterfaceRequest<Node>(channel));
}