'how to convert the double qoute to backtick

I'm trying to create a message string with a dynamic variable.

var name="venkat";
var message ="hello ${name}"

but this does not works, so i use backtick to achieve this

var name="venkat";
var message =`hello ${name}`

My question is there is any way to covert "" => ``



Solution 1:[1]

When not accessing object properties, you should simply use the dollar sign, without the brackets:

String name = "venkat";
String message = "Hello $name";

For accessing an object property:

Person newPerson = Person(name: "venkat");
String message = "Hello ${newPerson.name}";

Or do you have other reasons why you want to programmatically swap double quotes for backticks?


https://dart-lang.github.io/linter/lints/unnecessary_string_interpolations.html

String interpolation

Solution 2:[2]

Try escape \ will works.

var message ="\`hello ${name}\`"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 João Soares
Solution 2 Aryung