Oto-obong Eshiett
Oto-obong Eshiett

Reputation: 1679

How to add a Quotation mark to a variable in dart

I have a variable in declared in flutter and I want to print it as a string with a quotation mark around it something like this:

String name = "samuel";

so when I print it out I would get double quotations around it


"Samuel"

i tried

 print("'" + name +"'")

print('"' + name + '"')

print("\"" + name + "\"")

but none worked. Please, how can I achieve this in dart?

Upvotes: 0

Views: 3155

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657158

You can use

  • different outer quotes
print('"$name"')
print("'$name'") // prints ' quotes
  • escape quotes
print('\"$name\"')

Upvotes: 1

Related Questions