Google celebrates Hispanic Heritage Month. See how.

connectToService<T> method

*[<Null safety>](*

void connectToService <T>(AsyncProxy<T>? serviceProxy, {String? name})

Connects to the incoming service specified by serviceProxy.

If this object is not bound via the request method before this method is called an IncomingStateException will be thrown.

If name is specified, it is used as the service name to connect to, instead of the default name provided by the proxy.


void connectToService<T>(AsyncProxy<T>? serviceProxy, {String? name}) {
  if (serviceProxy == null) {
    throw ArgumentError.notNull('serviceProxy');
  final String? serviceName = name ?? 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();

      serviceName, serviceProxyRequest.passChannel());