美文网首页
flutter 文本上下角标显示,如角度、温度

flutter 文本上下角标显示,如角度、温度

作者: 天国镜 | 来源:发表于2022-03-10 09:35 被阅读0次

在项目中,很多时候在文本显示时,会有上下角标字符,Flutter具有这些字符的内置常量,有常用字符集库。例如,“上标1”为sup1,“上标2”为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"),
),

相关文章

网友评论

      本文标题:flutter 文本上下角标显示,如角度、温度

      本文链接:https://www.haomeiwen.com/subject/halfdrtx.html