# capitalizeAllWordsFirstLetter property

String get capitalizeAllWordsFirstLetter

Capitalize only the first letter of each word in a string

## Implementation

    String get capitalizeAllWordsFirstLetter {
      String lowerCasedString = toLowerCase();
      String stringWithoutExtraSpaces = lowerCasedString.trim();

      if (stringWithoutExtraSpaces.isEmpty) {
        return "";
      }
      if (stringWithoutExtraSpaces.length == 1) {
        return stringWithoutExtraSpaces.toUpperCase();
      }

      List<String> stringWordsList = stringWithoutExtraSpaces.split(" ");
      List<String> capitalizedWordsFirstLetter = stringWordsList.map((String word) {
        if (word.trim().isEmpty) {
          return "";
        }
        return word.trim();
      }).where((String word) => word != "").map((String word) {
        if (word.startsWith(RegExp(r'[\n\t\r]'))) {
          return word;
        }
        return word[0].toUpperCase() + word.substring(1).toLowerCase();
      }).toList();

      String finalResult = capitalizedWordsFirstLetter.join(" ");
      return finalResult;
    }