Akash Gorai
Akash Gorai

Reputation: 671

Flutter Container not wrapping to size of container when alignment property is used

I have a container A and a container B such that container A contains container B. I expect the the container A to wrap itself to the size of the child ie. container B as a container is defined in Flutter doc.

It works as expected and the container A size wraps just to fit the Container B. Very well

However, when alignment property is used on the container A, the Container A extends full height without honouring the height of the container B.

Here is my code :

Container(
            alignment: Alignment.bottomLeft,
            child : Container(child: SizedBox(width:30, height: 300,), color: Colors.green,),
            width: 60,
            color: Colors.blue,
          )

How can I use alignment property of the container expecting normal behaviour?

enter image description here

Upvotes: 2

Views: 626

Answers (1)

LonelyWolf
LonelyWolf

Reputation: 4392

According to chat conversation this is the required outcome

Container( 
color: Colors.red, 
child: Row( 
children: <Widget>[ 
Container( 
height: 300, 
width: 30, 
color: Colors.green, 
) 
], 
), 
)

I have a second question on this regard..if you can answer. What if i reverse my case and would want to have my child align to right and have a breather space to its left?

Add mainAxisAlignment: MainAxisAlignment.end inside your row

Upvotes: 1

Related Questions