Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$ sign in a Text widget , how to show special characters in flutter? how to set special character to text widget in flutter

I am trying to write a $ sign in a Text

Text("Refer and Win 10 000 $")

I get an error

enter image description here

What is the correct way to write this?

like image 345
Tree Avatar asked Dec 17 '22 22:12

Tree


2 Answers

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

like image 97
Felix Avatar answered Feb 16 '23 01:02

Felix


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'))),

List of special characters

like image 20
Quick learner Avatar answered Feb 16 '23 00:02

Quick learner