flutter - 颤振文本溢出
问题描述
如果不知道框的 const 宽度,如何控制 TextOverFlow。我知道
Text(
'some Text',
overflow: TextOverflow.ellipsis,
)
但是有什么方法可以包装扩展或灵活的小部件?
解决方案
FittedBox(
fit: setToWidth ? BoxFit.contain : BoxFit.none,
child: Text(
displayText,
maxLines: 2,
textAlign: textAlign,
style: setToWidth
? TextStyle(
fontWeight: fontWeight,
color: textColor,
fontFamily: AppFonts.circularStd,
)
: TextStyle(
fontWeight: fontWeight,
color: textColor,
fontFamily: AppFonts.circularStd,
fontSize: textSize),
),
);
试试这个
推荐阅读
- javascript - 用aCoords tl,br角而不是顶部绘制矩形,留在fabric.js中?
- swiftui - 小部件 SwiftUI 中的文本阴影不起作用
- javascript - 数据未在本机反应中使用 Flatlist 呈现
- c# - 使用 MixedReality-WebRTC 屏幕捕获
- javascript - 在使用 javascript 设置 CSS 之前简要显示默认 CSS
- flutter - 使对话框忽略 Flutter 中的默认主题
- javascript - 当我运行 JS 代码时,我的 html 文件消失了
- reactjs - 使用反应延迟加载获取超过 1000 条数据记录
- javascript - ES6 类私有属性只是语法糖吗?
- django - 从路径变量 url Django 获取 id