getUriBaseHostAndPort function

String getUriBaseHostAndPort({
  1. bool suppressPort80 = true,
  2. int? port,
})

The host and port of base Uri.

suppressPort80 if true suppresses port 80 and returns only the host.

Implementation

String getUriBaseHostAndPort({bool suppressPort80 = true, int? port}) {
  var uri = getUriBase();
  port ??= uri.port;

  if (suppressPort80 && port == 80) {
    return uri.host;
  }

  if (port == 0) {
    return uri.host;
  }

  return '${uri.host}:$port';
}