isEncoded static method
Checks if a string appears to be already URL encoded
Implementation
static bool isEncoded(String string) {
if (string.isEmpty) return false;
// Check for typical URL encoding patterns like %20, %3A, etc.
final hasEncodedChars = RegExp(
r'%[0-9A-F]{2}',
caseSensitive: false,
).hasMatch(string);
// Double-encoded strings (e.g. %253A) are not considered properly encoded —
// normalizeUrlEncoding should be used to fix them first.
final hasDoubleEncoding = RegExp(
r'%25[0-9A-F]{2}',
caseSensitive: false,
).hasMatch(string);
return hasEncodedChars && !hasDoubleEncoding;
}