可以使用 'TextStyle' 的 'height' 属性来控制文字的行高,从而实现文字的垂直居中。

例如,可以设置一个行高为 1.0 的 'TextStyle':

Text(
  'Hello World',
  style: TextStyle(
    fontSize: 24,
    height: 1.0,
  ),
)

这样,文字就会在容器中垂直居中显示。如果需要调整行高,可以根据需要调整 'height' 的值。

Flutter 文字垂直居中:使用 TextStyle 的 height 属性

原文地址: https://www.cveoy.top/t/topic/gpUm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录