Flutter对字体的左右对齐可以通过TextAlign属性来实现。TextAlign属性有三个值:left、center和right,分别表示左对齐、居中对齐和右对齐。

例如:

Text(
  'Hello World',
  textAlign: TextAlign.center,
);

上面的代码将文本居中对齐。

如果想要实现文本左右对齐,可以使用Row组件。将文本放在Row组件中,然后使用MainAxisAlignment属性来控制文本的位置。

例如:

Row(
  mainAxisAlignment: MainAxisAlignment.spaceBetween,
  children: [
    Text('Left'),
    Text('Right'),
  ],
);

上面的代码将两个文本左右对齐。MainAxisAlignment.spaceBetween属性会让两个文本之间有空隙,让它们分别靠左和靠右对齐。

flutter对字体做左右对齐

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

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