THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.
In these examples, Learn how to capitalize the first letter of a string or statement in Dart programming with examples.
The string contains a group of words separated by spaces and enclosed in single or double-quotes.
For example, if the string contains ‘hello world’, capitalize of a string is ‘Hello world’.
In this example, Written capitalizeFirstLetter function
Here is an example
void main() {
print(capitalizeFirstLetter('hello world'));
}
String capitalizeFirstLetter(String str) => str[0].toUpperCase() + str.substring(1);
Output:
Hello world
Another way using string append with interpolation syntax
void main() {
String message = 'hello world';
print('${message[0].toUpperCase()}${message.substring(1).toLowerCase()}');
}
🧮 Tags
Recent posts
How to Convert String to Int in swift with example How to Split a String by separator into An array ub swift with example How to disable unused code warnings in Rust example Golang Tutorials - Beginner guide Slice Examples Golang Array tutorials with examplesRelated posts