getHostName static method

String getHostName(
  1. String url
)

Implementation

static String getHostName(String url) {
  final regex = RegExp(r'^(?:https?:\/\/)?(?:www\.)?([^\/]+).*$');
  return regex.firstMatch(url)?.group(1) ?? '';
}