2

Here's my widget tree that's causing me the problems:

Container(
  margin: EdgeInsets.all(15),
  child: Row(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: <Widget>[
      ClipRRect(
        borderRadius: cardBorderRadius,
        child: Image(
          image: NetworkImage(widget.article["thumbnail"]),
          width: MediaQuery.of(context).size.width * .18,
          height: MediaQuery.of(context).size.width * .18,
          fit: BoxFit.cover,
        ),
      ),
      Container(
        margin: EdgeInsets.only(left: 15),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Container(
              padding: EdgeInsets.only(top: 15),
              child: Text(
                widget.article["title"],
                overflow: TextOverflow.clip,
                style: TextStyle(
                  fontWeight: FontWeight.w700,
                  fontSize: 28,
                ),
              ),
            ),
            Container(
              padding: EdgeInsets.only(top: 20),
              child: Row(
                children: <Widget>[
                  Container(
                    margin: EdgeInsets.only(right: 5),
                    child: Icon(Icons.star_border, size: 15),
                  ),
                  Text(
                    '${widget.article["readTime"] ~/ 60} min',
                    overflow: TextOverflow.clip,
                    maxLines: 3,
                    softWrap: true,
                    style: TextStyle(
                      fontWeight: FontWeight.w500,
                      fontSize: 14,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    ],
  ),
);

Now the problem is I am getting this effect rather than text get clipped.

enter image description here

Note: I have tried other answers as well using the Expanded & Flexible widgets but none of them worked for me.

Any help will be appreciated!

2
  • Can you post some sample data. Commented Jul 10, 2020 at 9:47
  • I have a complex arrangement, can you please insert on your own by removing the variable values Commented Jul 10, 2020 at 11:00

1 Answer 1

2

Put the textfield into a flexible widget like this (work for me):

            Row(
              children: <Widget>[
                Flexible(
                  child: Text(
                    "some text",
                    textAlign: TextAlign.start,
                    overflow: TextOverflow.ellipsis,
                  ),
                ),
              ... more widgets
              ],
            ),
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the answer but this isn't working in my case
@YogeshAggarwal so why you mark it as answer?
Thanks! Works for my case, where I have a Text widget inside a nested Row (within a Column). Text was overflowing without the Flexible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.