在项目中,很多时候在文本显示时,会有上下角标字符,Flutter具有这些字符的内置常量,有常用字符集库。例如,“上标1”为sup2,等等。它还包括希腊字符和许多其他内容。
1、导入字符集库
//根据需要导入
import 'package:charcode/ascii.dart' as Ascii;
import 'package:charcode/html_entity.dart' as HtmlEntity;
2、文本Text、富文本RichText使用上下标字符
相对相应字符集,可查看charcode library,找到需要的字符进行显示
//度数 °
String deg = String.fromCharCode(HtmlEntity.$deg);
Container(
alignment: Alignment.center,
height: 60.px,
child: Text("今天温度:27 ${deg}C"),
),
网友评论