isLiteralToken static method
Determines whether key is a literal UI token (such as a hashtag, handle,
URL, phone number, or email address) rather than a translatable dictionary key.
Implementation
static bool isLiteralToken(String key) {
if (key.isEmpty) return true;
final trimmed = key.trim();
if (trimmed.startsWith('#') || trimmed.startsWith('@')) {
return true;
}
if (trimmed.startsWith('http://') ||
trimmed.startsWith('https://') ||
trimmed.startsWith('mailto:') ||
trimmed.startsWith('tel:')) {
return true;
}
if (trimmed.startsWith('+') || _phoneNumberRegex.hasMatch(trimmed)) {
return true;
}
if (_emailRegex.hasMatch(trimmed)) {
return true;
}
return false;
}