toProperCase function

String toProperCase(
  1. String text
)

Implementation

String toProperCase(String text) {
  return text
      .split(' ')
      .map(
        (word) =>
            word.isNotEmpty
                ? word[0].toUpperCase() + word.substring(1).toLowerCase()
                : '',
      )
      .join(' ');
}