isUpperCase property

bool get isUpperCase

True if every character is already uppercase OR is a non-letter. (e.g. 'HELLO', '123!?', '' -> true; 'Hello' -> false)

Implementation

bool get isUpperCase {
  if (isEmpty) return true;
  final hasLetter = RegExp(r'\p{L}', unicode: true);
  final onlyUpperOrNonLetters = RegExp(
    r'^(?:\p{Lu}|\P{L})+$',
    unicode: true,
  ).hasMatch(this);
  // If there are letters, they must be upper; digits/punct are fine.
  return !hasLetter.hasMatch(this) || onlyUpperOrNonLetters;
}