【问题标题】:How can I make the text from the widget wrap?如何使小部件中的文本换行?
【发布时间】:2020-10-22 12:34:20
【问题描述】:

我有以下代码:

GridTile(
      footer: Material(
          color: Colors.transparent,
          shape: const RoundedRectangleBorder(
              borderRadius: BorderRadius.vertical(bottom: Radius.circular(4))),
          clipBehavior: Clip.antiAlias,
          child: GridTileBar(
            backgroundColor: Colors.black45,
            title: Flexible(
                child: Text(
              exam.examSpecifications.subject,
              overflow: TextOverflow.clip,
            )),
            subtitle: Text(exam.examSpecifications.examName),
          )),
      child: exam.examImage,
    );
  }

我得到的是以下行为:

理想情况下,我希望它显示为

   Some Other
   Subject
   Some Other ...

有没有办法做到这一点?

【问题讨论】:

  • 您希望您的文本在词尾后输入吗?
  • 没错,我希望它可以中断并继续下一行。

标签: flutter user-interface dart


【解决方案1】:

我希望我能理解你想要什么。您可以像下面的代码一样设置标题文本的溢出和 softWrap 属性并删除灵活小部件:

title: Text(
                  exam.examSpecifications.subject,
                  overflow: TextOverflow.visible,
                  softWrap: true,
                ),

【讨论】:

  • 这正是我想要的。我不知道 softWrap 属性。谢谢!
猜你喜欢
  • 2012-02-14
  • 1970-01-01
  • 2021-11-12
  • 1970-01-01
  • 2021-04-01
  • 2018-11-08
  • 2016-01-04
  • 2020-09-10
  • 2023-03-07
相关资源
最近更新 更多