4

How to remove the column space between Card ?

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Sample"),
      ),
      body: Column(
        children: <Widget>[
          Card(
              child: Padding(
            padding: EdgeInsets.all(15),
            child: Text("Card 1"),
          )),
          Card(
            child: Padding(padding: EdgeInsets.all(15), child: Text("Card 2")),
          )
        ],
      ),
    );
  }

Output

d

John Joe
  • 12,412
  • 16
  • 70
  • 135

3 Answers3

12

By default, the card widget has a default margin set to 4.0 logical pixels , to eliminate the spaces, you can adjust the default margin to your preference:

I added a demo using your widget tree as an example:

Column(
                children: <Widget>[
                  Card(
                    // set the margin to zero
                    margin: EdgeInsets.zero,
                    child: Text("Card 1"),
                  ),
                  Card(
                    // set the margin to zero
                    margin: EdgeInsets.zero,
                    child: Text(
                      "Card 2",
                    ),
                  )
                ],
              ),
void
  • 12,787
  • 3
  • 28
  • 42
1

The error is because you using. padding: EdgeInsets.all(15) in your card. You Can alloy padding only on the required sides. In the card try adding margin:EdgeInsets.zero

 Card(
        margin: EdgeInsets.zero,
     ),
S.R Keshav
  • 1,965
  • 1
  • 11
  • 14
0

The default margin in Flutter is 4.0 pixels on all sides. To change this set

margin: EdgeInsets.zero 

To learn more about margins go here

Eli Front
  • 695
  • 1
  • 8
  • 28