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

 在项目中,很多时候在文本显示时,会有上下角标字符,Flutter具有这些字符的内置常量,例如,“上标1”为$sup1,“上标2”为$sup2,等等。它还包括希腊字符和许多其他内容。

1、在pubspec.yaml引入 charcode

charcode: ^1.3.1

2、导入字符集库

//根据需要导入
import 'package:charcode/ascii.dart' as Ascii;
import 'package:charcode/html_entity.dart' as HtmlEntity;

 3、文本Text、富文本RichText使用上下标字符

//度数 °
String deg = String.fromCharCode(HtmlEntity.$deg);
Container(
  alignment: Alignment.center,
  height: 60.px,
  child: Text("今天温度:27 ${deg}C"),
),

猜你喜欢

转载自blog.csdn.net/lqw200931116/article/details/123392806