A.A
A.A

Reputation: 4101

Dart String Interpolation - $ started variables

How we can use a variable started with $ in a string interpolation?

What is a string interpolation equivalent of the following string concatenation?

final String $foo = 'Foo';

print('my variable is '+ $foo);

Note: it is useful when we have a variable started with _ and want to make it public, i.e a JSON field named _ , can be converted to $_ in dart

Upvotes: 3

Views: 643

Answers (1)

A.A
A.A

Reputation: 4101

final String $foo = 'Foo';

print('my variable is ${$foo}');

Upvotes: 3

Related Questions