0

I want the second column of cards to be slightly uneven how can I achieve that. here is the output that I want:

enter image description here

2
  • You can use flutter_staggered_grid_view: ^0.4.0 plugin for list layout. Commented Jul 1, 2021 at 11:55
  • Yes, I have seen that package but I couldn't find this particular solution if you help me defining some values or code that would really help thanks @krisha dhankecha Commented Jul 1, 2021 at 12:02

2 Answers 2

2

You can use GridView.builder like this

GridView.builder(
  padding: EdgeInsets.only(left: 20, right: 20),
  shrinkWrap: true,
  physics: NeverScrollableScrollPhysics(),
  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
    crossAxisCount: 2,
    crossAxisSpacing: 20,
    mainAxisSpacing: 8,
    childAspectRatio: 0.7,
  ),
  itemCount: 10,
  itemBuilder: (context, index) {
    return Padding(
      padding: (index % 2) == 0 ? EdgeInsets.only(bottom: 15) : EdgeInsets.only(top: 15),
      child: Card(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(10),
        ),
        child: Container(
          decoration: BoxDecoration(
            color: (index % 2) == 0 ? Colors.red : Colors.green,
            borderRadius: BorderRadius.circular(10),
          ),
        ),
      ),
    );
  },
);
Sign up to request clarification or add additional context in comments.

7 Comments

thanks, but can I use cards instead of Containers?
Then wrap container with card and give it same border radius
I have edited my answer with card, Please take a look.
yup that looks good, but if I have to give more padding to the second card then it's just making the size smaller, like if I am changing the value of EdgeInsets.only(top: 15)
card height depends on childAspectRatio, make change in this parameter.
|
0

One approach would be to add two columns inside a row:

Row(
  children: [
    Expanded(
      child: Column(
        children: [
          CardWidget(/*...*/),
          CardWidget(/*...*/),
          CardWidget(/*...*/),
          CardWidget(/*...*/),
        ],
      ),
    ),
    Expanded(
      child: Column(
        children: [
          const SizedBox(
            height: 50,
          ),
          CardWidget(/*...*/),
          CardWidget(/*...*/),
          CardWidget(/*...*/),
          CardWidget(/*...*/),
        ],
      ),
    ),
  ],
);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.