startConnect method Null safety

Future<ConnectionTask<Socket>> startConnect (
  1. dynamic host,
  2. int port,
  3. {dynamic sourceAddress}
)

Like connect, but returns a Future that completes with a ConnectionTask that can be cancelled if the Socket is no longer needed.

Implementation

static Future<ConnectionTask<Socket>> startConnect(host, int port,
    {sourceAddress}) {
  final IOOverrides? overrides = IOOverrides.current;
  if (overrides == null) {
    if (!isInsecureConnectionAllowed(host)) {
      throw new SocketException(
          "Insecure socket connections are disallowed by platform: $host");
    }
    return Socket._startConnect(host, port, sourceAddress: sourceAddress);
  }
  return overrides.socketStartConnect(host, port,
      sourceAddress: sourceAddress);
}