capitalize method
Returns a copy of this string with the first character uppercased.
'hello'.capitalize(); // "Hello"
''.capitalize(); // ""
'h'.capitalize(); // "H"
Implementation
String capitalize() {
if (isEmpty) return '';
return '${this[0].toUpperCase()}${substring(1).toLowerCase()}';
}