Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special characters in Flutter

Tags:

flutter

dart

How can I add a special character (e.g., copyright sign instead of (c)) in the following example:

Widget copyrightText = new Container(   padding: const EdgeInsets.only(left: 32.0, right: 32.0),   child: Text('2018 (c) Author's Name'), ); 
like image 206
Mary Seleznova Avatar asked Apr 27 '18 10:04

Mary Seleznova


People also ask

How do you use special characters in flutter?

How do you add special characters to a string in flutter? Escaping every special character. Like many programming languages, you can escape special characters in a Dart string by using “\” (backslash). Display text as a raw string.

How do you get rid of special characters in flutter?

How do you remove a character from a string in flutter? We have used the replaceAll() method on string with RegEx expression to remove the special characters. It will give you the alphabets and numbers both and Special characters will be removed.


2 Answers

You can add it as unicode like

 child: new Text('2018 \u00a9 Author's Name'), 

or

 child: new Text('2018 © Author's Name'), 

See also

  • How can I write a 3 byte unicode character as string literal
like image 50
Günter Zöchbauer Avatar answered Sep 19 '22 17:09

Günter Zöchbauer


Only one other thing to add.

Dart/Flutter add another concept of "Runes" which are integer/Unicode representations of Strings (beyond what you can type) ... e.g.

var myRichRunesMessage = new Runes('2018 \u00a9 Author\'s Name \u{1f60e}'); print(new String.fromCharCodes(myRichRunesMessage)); 

Which would render something like this ...

copyright and emoji

Pretty cool capability to enable characters not generally typeable on many keyboards - even Emoji :-) ...

like image 31
babernethy Avatar answered Sep 20 '22 17:09

babernethy