isTitleCaseWord function

bool isTitleCaseWord(
  1. String word
)

Returns true when word follows strict ASCII title-case.

A strict title-case word has an uppercase first letter and lowercase letters for all remaining characters.

Implementation

bool isTitleCaseWord(String word) {
  if (word.isEmpty) {
    return false;
  }

  final int first = word.codeUnitAt(0);
  if (!isUpper(first)) {
    return false;
  }

  for (int i = 1; i < word.length; i++) {
    final int code = word.codeUnitAt(i);
    if (!isLower(code)) {
      return false;
    }
  }

  return true;
}