$ sign in a Text widget , how to show special characters in flutter? how to set special character to text widget in flutter
9,369
Solution 1
As @Davy M mentioned, you have to escape the $
because it's used as a control character for embedding variables in a string.
See the Dart docs: https://www.dartlang.org/guides/language/language-tour#strings
Solution 2
You can use Runes
class which does not need any plugin
Example
You want to show Dollar sign and you know its unicode value ie U+0024
Now to show it in text you can use Runes
class and convert it to show Dollar sign ($)
Just need to use the unicode value after U+
ie 0024
and then append it with \u
Usage
Text(new String.fromCharCodes(new Runes('\u0024'))),
Author by
Tree
Updated on December 05, 2022Comments
-
Tree over 1 year
I am trying to write a $ sign in a Text
Text("Refer and Win 10 000 $")
I get an error
What is the correct way to write this?
-
Llama over 3 yearsyou reference the docs without answering the question..... One can use the '\' character to escape in flutter --> '\$' will allow you the include the $ character within your string