connectToService<T> method

*<Null safety>*

void connectToService <T>(AsyncProxy<T>? serviceProxy)

Implementation

void connectToService<T>(AsyncProxy<T>? serviceProxy) {
  if (serviceProxy == null) {
    throw ArgumentError.notNull('serviceProxy');
  }
  final String? serviceName = serviceProxy.ctrl.$serviceName;
  if (serviceName == null) {
    throw Exception(
        "${serviceProxy.ctrl.$interfaceName}'s controller.\$serviceName must "
        'not be null. Check the FIDL file for a missing [Discoverable]');
  }

  // Creates an interface request and binds one of the channels. Binding this
  // channel prior to connecting to the agent allows the developer to make
  // proxy calls without awaiting for the connection to actually establish.
  final serviceProxyRequest = serviceProxy.ctrl.request();

  connectToServiceByNameWithChannel(
      serviceName, serviceProxyRequest.passChannel());
}