getUrl function

Uri getUrl(
  1. Object address,
  2. int port,
  3. bool isSecure
)

Makes a Uri for Server.

Implementation

Uri getUrl(Object address, int port, bool isSecure) {
  String host;

  if (address is InternetAddress) {
    if (address.isLoopback) {
      host = 'localhost';
    } else if (address.type == InternetAddressType.IPv6) {
      host = '[${address.address}]';
    } else {
      host = address.address;
    }
  } else {
    host = address as String;
  }

  return Uri(scheme: isSecure ? 'https' : 'http', host: host, port: port);
}