encodeFileName function
Generate a unique, reversible filename from a URL
Implementation
String encodeFileName(String url) {
// Remove http://, https://, and www.
String cleanedUrl = url.replaceFirst(RegExp(r'^https?:\/\/(www\.)?'), '');
// Base64 URL-safe encoding without padding
return base64UrlEncode(utf8.encode(cleanedUrl)).replaceAll('=', '');
}