是否可以使 Flutter 中的字符具有相同的宽度? [英] Is it possible to make characters in Flutter to have the same width?

查看:15
本文介绍了是否可以使 Flutter 中的字符具有相同的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如下图所示,文本具有相同数量的字符,但由于数字1"比5"更纤细和2",两个文本的宽度不同.

As you can see in the picture below, the texts have the same amount of characters, but since the number "1" is slimmer than the "5" and "2", both texts get a different width.

如何在 Flutter 中进行调整?

How can I adjust that in Flutter?

推荐答案

可以设置字体功能使用tabularFigures.

You can set the font feature to use tabularFigures.

// import 'dart:ui';

Text(
  _getTimeString(),
  style: TextStyle(
    fontFeatures: [
      FontFeature.tabularFigures()
    ],
  ),
),

之前:

之后:

另见:

这篇关于是否可以使 Flutter 中的字符具有相同的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆