extractDomain property
String?
get
extractDomain
Extracts the domain name from a URL
Example:
String url = "https://www.google.com";
print(url.extractDomain); // google.com
Implementation
String? get extractDomain {
try {
Uri uri = Uri.parse(this);
return uri.host.isNotEmpty ? uri.host : null;
} catch (e) {
return null;
}
}