首页 > 解决方案 > 颤振文本溢出

问题描述

如果不知道框的 const 宽度,如何控制 TextOverFlow。我知道

Text(
      'some Text',
      overflow: TextOverflow.ellipsis,
)

但是有什么方法可以包装扩展或灵活的小部件?

标签: flutterflutter-layoutflutter-text

解决方案


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),
      ),
    );

试试这个


推荐阅读