capitalize method

String capitalize()

Return a String with its first character UpperCase and the rest LowerCase.

Example :

print('this'.capitalize()); // 'This'
print('THIS'.capitalize()); // 'This'

Implementation

String capitalize() =>
    isNotEmpty ? first.toUpperCase() + substring(1).toLowerCase() : this;