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

查看:245
本文介绍了是否可以使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.

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

之前:

之后:

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

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