2

My issue is that I want to display Text widget in my grid view and each one of these widgets has its own content and can have different width, I am facing trouble with achieving that…

enter image description here

this is widgets don't show the content of its child

1
  • Can you include your code-snippet? Commented Apr 10, 2022 at 20:22

1 Answer 1

11

For this case, you can use Wrap widget.

Padding( //outer spacing
  padding: const EdgeInsets.all(8.0),
  child: Wrap(
    spacing: 8, // space between items
    children: ["Java", "Nodejs"]
        .map((e) => Container(
              padding: EdgeInsets.all(8),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(4),
              ),
              child: Text(e),
            ))
        .toList(),
  ),
)

More about Wrap widget.

Sign up to request clarification or add additional context in comments.

5 Comments

Glad to help you out, you can accept as answer while it solves your issue, you can find more about What should I do when someone answers my question?
Doesn't really solve the issue as wrap has different sizes. Would be nice to use gridview as it looks better design wise.
@OliverDixon you may right but the question is Grid view with dynamic width and height
@YeasinSheikh just setting width on wrap has the same effect ;_)
It will be easier if you ask a new question by providing minimal snippet, Then I might be able to get it.

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.