upperCaseFirstChar method

  1. @useResult
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

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