flutter - 如何在颤动中同时换行和缩小文本?
问题描述
我在圆形容器中有一个文本,该文本来自 API。所以我无法控制文本的长度。我通过使用 FittedBox 缩小它来显示容器内的文本,不管它有多长。
Container(
height: 44,
width: 44,
padding: EdgeInsets.all(3),
alignment: Alignment.center,
child: Row(
children: [
Flexible(
child: FittedBox(
child: Text('Best Seller'),
),
),
],
),
decoration: BoxDecoration(shape: BoxShape.circle, color: Color(0xFFF37C43)),
)
我的问题是如何在新行中显示文本的所有单词,同时缩小它们。我正在考虑使用 Column 并从文本的每个单词生成子小部件。但这似乎不是很直观。如果需要,我愿意更改我的布局设计。
解决方案
使用自动大小文本。这是链接 https://pub.dev/packages/auto_size_text
推荐阅读
- angular - 星云角色 - isGranted() 始终为真
- python - 根据随机变量的值将值分配给 DataFrame 列
- google-sheets - 简单现金簿中总计的数组公式
- vue.js - 带有 baseurl 和公共路径的 Nginx 和 Vuejs 3 配置
- python - 如何将列表序列化回其原始二进制数据库?
- r - R错误地将日期作为第一个字段的.csv数据导入
- python - Anaconda Navigator 打不开,conda 也打不开
- javascript - 如何设置多个元素的文本内容
- javascript - 如何结合 3 个更改事件来隐藏 div
- swift - 更改导航按钮 SwiftUI 的颜色