首页 > 解决方案 > 在列中换行

问题描述

我正在构建一个费用应用程序,并且有: 在此处输入图像描述

如您所见,我遇到了文本溢出问题。我希望用省略号修剪该文本,但我不知道该怎么做。目前我有:


  Widget buildCardLeft() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Container(
          child: Text(
            this.transaction.title,
            style: TextStyle(fontSize: 24),
            overflow: TextOverflow.ellipsis,
          ),
        ),
        SizedBox(
          height: 8,
        ),
        Text(
          dateFormat.format(this.transaction.date),
          style: TextStyle(color: Colors.grey),
        )
      ],
    );

截断此文本的正确方法是什么?

标签: flutter

解决方案


你可以这样说:

Text(
this.transaction.title.replaceRange(25, this.transaction.title.length, "...",
style: TextStyle(fontSize: 24),
            overflow: TextOverflow.ellipsis,
)

推荐阅读