How to align a container in Flutter?

This Article is posted by seven.srikanth at 11/25/2022 5:14:53 AM



You can align a container by wrapping it inside an Align widget.

For example, the below code will set the container to topCenter.

You can set Alignment to topCenter, topRight, centerLeft, center, centerRight, bottomLeft, bottomCenter, or bottomRight.

Here is a simple example, that helps you to understand more about aligning the container.

color: #9cdcfe;](args)

color: #569cd6;](class color: #4ec9b0;](MyApp color: #569cd6;](extends color: #4ec9b0;](StatelessWidget ); color: #9cdcfe;](@ color: #9cdcfe;](override

color: #4ec9b0;](Widget color: #dcdcaa;](build(color: #4ec9b0;](BuildContext color: #9cdcfe;](context) { color: #c586c0;](return color: #4ec9b0;](Align( color: #9cdcfe;](alignment: color: #4ec9b0;](FractionalOffset., color: #9cdcfe;](child: color: #4ec9b0;](Container( color: #9cdcfe;](height: color: #b5cea8;](100, color: #9cdcfe;](width: color: #b5cea8;](100, color: #9cdcfe;](decoration: color: #569cd6;](const color: #4ec9b0;](BoxDecoration( color: #9cdcfe;](color: color: #4ec9b0;](Colors.color: #9cdcfe;](amber, ), ), ); } } `

Thanks, Srikanth


Tags:








0 Comments
Login to comment.
Recent Comments