0.8 C
New York
Monday, February 26, 2024

Dart: Capitalize the First Letter of Each Word in a String

The example below shows you how to capitalize the first letter of each word in a string in Dart (and Flutter as well).

The code:

void main() {
  String totTitle(String input) {
    final List<String> splitStr = input.split(' ');
    for (int i = 0; i < splitStr.length; i++) {
      splitStr[i] =
    final output = splitStr.join(' ');
    return output;

  final str1 = 'Kindacode.com is a website about programming.';
  final str2 = 'Today is a raining day!';


Kindacode.com Is A Website About Programming.
Today Is A Raining Day!

Further reading:

You can also check out our Flutter category page, or Dart category page for the latest tutorials and examples.


Related Articles

Latest Articles