问题
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