dart
String interpolation and formation in Dart
You can perform string interpolation and formation in dart language using ${expression}. We can perform a lot of string operations using this.
void main() {
//Concate strings using ${expression}
var name = 'Ankit';
print('My Name is: ${name}');
//Sum using ${expression}
var sum = sumFn(5, 10);
print(sum);
//uppercase letters using ${expression}
var uppercaseLetters = '${"john deo".toUpperCase()}';
print(uppercaseLetters);
}
String sumFn(int x, int y) {
return 'Sum is: ${(x+y).toString()}';
}
Output
My Name is: Ankit
Sum is: 15
JOHN DEO
Sum is: 15
JOHN DEO
Was this helpful?
Similar Posts
- Sort a list in ascending and descending order Dart or Flutter
- Remove empty and falsey values from a List in Dart/Flutter
- Remove empty lists from a list of lists and flatten it using Dart
- Dart Program to convert a number to string
- Convert string to integer Dart Program
- Dart program to capitalize the first letter of a string
- Check if a String is empty or null in Dart / Flutter