Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Container height same as parent height

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),
 ]
);
like image 596
aksn Avatar asked Jun 28 '18 08:06

aksn


2 Answers

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

Stack(
  children: [
    Card(),
    Positioned.fill(
      child: Container(color: Colors.red),
    )
  ]
);
like image 127
Rémi Rousselet Avatar answered Sep 27 '22 18:09

Rémi Rousselet


height: double.infinity 

It worked for me in case of container

like image 44
kulvinder Avatar answered Sep 27 '22 18:09

kulvinder