Thamidur Rashid
Thamidur Rashid

Reputation: 1

How do I render List and Grid on the same page in flutter?

I am trying to render GridView and ListView on the same page in Flutter, where the grid and list are not scrollable on their own but are scrollable as a whole page. The GridView and the ListView will be rendered, but they should have a discontinuous distribution of grid and list on the page.

Thanks in advance!

Upvotes: 0

Views: 482

Answers (1)

Michael Yuwono
Michael Yuwono

Reputation: 2617

Use primary: false and shrinkWrap: true to the GridView

return ListView(
  children: <Widget>[
    Container(
      height: 75,
      color: Colors.green,
      margin: const EdgeInsets.all(25),
    ),
    GridView.count(
      primary: false,
      shrinkWrap: true,
      crossAxisCount: 3,
      children: List<Widget>
        .generate(10, (_) => Container(
            color: Colors.red,
            margin: const EdgeInsets.all(25),
      )),
    ),
  ],
);

Upvotes: 1

Related Questions