Chrome Extension

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()}';
}
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Output
My Name is: Ankit
Sum is: 15
JOHN DEO
Was this helpful?
0 Comments
Join Devsheet Ask a Question