capitalize method

String capitalize()

Returns a new String by transforming the first character of this String to uppercase and all other characters to lowercase.

Implementation

String capitalize() => //
    length < 2 ? toUpperCase() : first.toUpperCase() + substring(1).toLowerCase();