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 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, the 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
Julia examples - Variable Type Nim example - Convert String to/from the Int How to get length of an array and sequence in Nim? Nim environment variables - read, set, delete, exists, and iterate examples? How to convert from single character to/from string in Nim?Related posts