简体   繁体   中英

Flutter Long Text breakline

I have a long text that doesn't break line. I suspect the wrap widget is giving this problem.

文字截图

Here's my code

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

I tried also to put expanded before the Text widget but nothing happens.

try to set softWrap property of Text widget true:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM