How to format an interpolated String

Dart supports string interpolation

var seconds = 5;
print("Send $seconds seconds ago");

var harryLikes="Silvia";
var otherName="Erik";
var otherLikes="Chess";
print("Harry like $harryLikes");
print("I think $otherName like $otherLikes");

Also more complex expressions can be embedded with ${...}

print('Calc 3 + 5 = ${3 + 5}');

The number types and the intl package provide more methods to format numbers and dates.

See for example:

  • https://www.dartdocs.org/documentation/intl/latest/intl/NumberFormat-class.html
  • Currency format in dart

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)