flutter中文字长度溢出时如何显示省略号?

经常在绘画UI的时候遇到这种问题,依据场景不同,说下我自己的常用方案:

1. 第一种就是给Text标签外层嵌套一层Container,并指定width宽度

2.第二种是自动适配模式,我常用于Text外层嵌套了Row和Column以及一些布局控件中

new Flexible( //长度自适应
  child: new Container(
    padding: new EdgeInsets.only(right: 13.0),
    child: new Text(
      'Text largeeeeeeeeeeeeeeeeeeeeeee',
      overflow: TextOverflow.ellipsis, //长度溢出后显示省略号
      style: new TextStyle(
        fontSize: 13.0,
        fontFamily: 'Roboto',
        color: new Color(0xFF212121),
        fontWeight: FontWeight.bold,
      ),
    ),
  ),
),

猜你喜欢

转载自blog.csdn.net/qq_25062671/article/details/127975430