upperCaseFirstChar method

String upperCaseFirstChar()

Converts the first character of the string to uppercase, leaving the rest of the string unchanged.

If the string is empty, it returns an empty string.

Returns: A new string with the first character in uppercase, or an empty string if the original string is empty.

Example:

'mixedCase'.upperCaseFirstChar(); // Returns 'MixedCase'
'UPPERCASE'.upperCaseFirstChar(); // Returns 'UPPERCASE'
''.upperCaseFirstChar();        // Returns ''

Implementation

String upperCaseFirstChar() => isEmpty ? '' : this[0].toUpperCase() + substring(1);