getLocalhostUrl function
Implementation
String getLocalhostUrl() {
if (kIsWeb) {
try {
final location = web.window.location;
final protocol = location.protocol;
final hostname = location.hostname;
final port = location.port;
return '$protocol//$hostname${port.isNotEmpty ? ':$port' : ''}';
} catch (e) {
error('Error while retrieving localhost URL: $e');
return '';
}
} else {
warn('Non-web environment detected');
return '';
}
}