15

I want to overlay a Card with a white container, but the container always needs a height (otherwise it's not displayed). I want it to be as big as its parent, the stack. How can I make this work? The height of the card varies. I guess I'm missing something ;)

return new Stack(
 children: <Widget>[
  new Card( ... ),
  new Container(color: Colors.white70),
 ]
);
aksn
  • 2,341
  • 4
  • 17
  • 21

2 Answers2

59

You can use a Positioned.fill to force a stack child to fill Stack.

Stack(
  children: [
    Card(),
    Positioned.fill(
      child: Container(color: Colors.red),
    )
  ]
);
Rémi Rousselet
  • 256,336
  • 79
  • 519
  • 432
14
height: double.infinity 

It worked for me in case of container

kulvinder
  • 529
  • 5
  • 17