Search code examples
flutterflutter-layoutflutter-widget

How to draw widget on available height in flutter


I have a widget that needs to draw on the remaining height where that widget needs to be drawn in between the top and bottom widget(Bottom widget drawn with bottom center attribute).

Ex:

Container() -- The First container almost take half screen

Container() -- The Second container draw on the bottom of the screen eg: Consider widget as Button

Container() -- The Third Container needs to be drawn in between two containers.


Solution

  • The Expanded widget would work for this scenario where we need to wrap middle widget with it.

    Eg:

    Expanded(
            child: Container(
                  ...         
                ),
             ),