isMixedCase function

bool isMixedCase(
  1. String token
)

Returns true if the token is mixed-case (e.g., 'OpenAI').

Implementation

bool isMixedCase(String token) {
  if (token.length < minMixedCaseTokenLength) return false;
  final String alpha = token.replaceAll(RegExp(r'[^A-Za-z]'), '');
  if (alpha.isEmpty) return false;

  bool hasUpper = false;
  bool hasLower = false;
  // Check if we have both upper and lower after the first character
  // (Title Case is handled separately by the dictionary)
  for (int i = 1; i < alpha.length; i++) {
    if (alpha[i] == alpha[i].toUpperCase()) hasUpper = true;
    if (alpha[i] == alpha[i].toLowerCase()) hasLower = true;
  }
  return hasUpper && hasLower;
}