Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter column doesn't expand

Tags:

I am a complete newbie in Flutter, but I already like it. The question is: why is the column not expanding to the full height?

code is on gist.github

screenshot

like image 952
Nikita Kraev Avatar asked Mar 15 '18 22:03

Nikita Kraev


People also ask

How do you expand a column in flutter?

A Column widget is flexible - it will try to take up as much space as it needs but no more. If you want it to take up all availible space, then wrap it in an Expanded widget. This only works if the Column is inside another Flex widget, as Expanded can only be placed inside a Flex widget.

How do I expand my rows to flutter?

You can make the children of Row widget, expand to the available horizontal space. All you need to do is, wrap each child of Row widget around Expanded widget.

How do you use expanded flex in flutter?

Using an Expanded widget makes a child of a Row, Column, or Flex expand to fill the available space along the main axis (e.g., horizontally for a Row or vertically for a Column). If multiple children are expanded, the available space is divided among them according to the flex factor.


1 Answers

A Column widget is flexible - it will try to take up as much space as it needs but no more. If you want it to take up all availible space, then wrap it in an Expanded widget.

createChildren() {   return [     Image.network(       testImg,       height: imageSize,       width: imageSize,     ),     Padding(padding: EdgeInsets.only(left: 16.0)),     Expanded(child:       Column(         crossAxisAlignment: CrossAxisAlignment.start,         mainAxisAlignment: MainAxisAlignment.spaceBetween,         children: [           boldText("Some title"),           Text("Address"),           Text("Description")         ],       ),     ),   ]; } 
like image 92
Jonah Williams Avatar answered Oct 17 '22 05:10

Jonah Williams