Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove space between Card

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

like image 854
John Joe Avatar asked Sep 05 '25 04:09

John Joe


1 Answers

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",
                    ),
                  )
                ],
              ),
like image 162
V.N Avatar answered Sep 07 '25 17:09

V.N