Mouayad
Mouayad

Reputation: 173

Flutter Grid view with dynamic width and height

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

Upvotes: 2

Views: 7694

Answers (1)

Md. Yeasin Sheikh
Md. Yeasin Sheikh

Reputation: 63604

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.

Upvotes: 11

Related Questions