颤抖的长文本断线

时间:2020-11-06 15:14:00

标签: flutter flutter-layout

我有一个不间断的长文本。我怀疑自动包装小部件正在解决此问题。

Text Screenshot

这是我的代码

SafeArea(
    child: SingleChildScrollView(
        physics: ScrollPhysics(),
        child: Container(
          child: ColumnSuper(
              innerDistance: -0.5,
              alignment: Alignment.topCenter,
              children: [
                Container(
                  width: MediaQuery.of(buildContext).size.width,
                  child: Wrap(children: [
                    GestureDetector(
                      onTap: () => checkNav(buildContext, linkProtection),
                      child: Container(
                        alignment: ali,
                        margin: margin,
                        padding: padding,
                        decoration: BoxDecoration(
                          border: border,
                          color: backgroundColor,
                          borderRadius: BorderRadius.circular(borderRadius),
                        ),
                        child: Text(
                          """$text""",
                          maxLines: 5,
                          textAlign: TextAlign.start,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(
                              color: titleColor,
                              fontSize: titleSize * 1.2,
                              height: titleLineHeight,
                              letterSpacing: titleSpa,
                              fontStyle: titleStyle,
                              decoration: titleDecoration,
                              fontWeight: titleWeight),
                        ),
                      ),
                    ),
                  ]),
                ),
              ]),
        )),
  );

我也尝试在Text小部件之前放置扩展,但是什么也没发生。

1 个答案:

答案 0 :(得分:0)

尝试将“文本”小部件的softWrap属性设置为true:

Text(
     """$text""",
     maxLines: 5,
     textAlign: TextAlign.start,
     overflow: TextOverflow.ellipsis,
     softWrap: true,
     style: TextStyle(
     color: Colors.green,
   ),
 ),