Special characters in Flutter

泪湿孤枕 提交于 2020-12-25 07:03:01

问题


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

回答1:


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



回答2:


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 ...

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




回答3:


To add any special character, You can use its unicode.

The unicode for Copyright Sign is 00a9

You can use it like this: new Text("2018 \u00a9 Author's Name");

You can find unicode of any characters from here.



来源:https://stackoverflow.com/questions/50060648/special-characters-in-flutter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!