capitalizeFirst method

String capitalizeFirst()

Capitalizes only the first letter of the string.

Example:

print('hello world'.capitalizeFirst()); // Hello world

Implementation

String capitalizeFirst() {
  if (isEmpty) return '';
  if (length == 1) return toUpperCase();
  return substring(0, 1).toUpperCase() + substring(1);
}