toCapitalCase property

String get toCapitalCase

Converts the string to capital case (first letter of each word capitalized).

Implementation

String get toCapitalCase => split(' ')
    .map(
      (String word) => word.isNotEmpty
          ? word[0].toUpperCase() + word.substring(1).toLowerCase()
          : '',
    )
    .join(' ');