Child Property

Provide a child widget to be contained by the container, the container will wrap the width & height of this child.

This widget can only have one child. To lay out multiple children, let this widget’s child be a widget such as Row, Column, or Stack, which have a children property, and then provide the children to that widget.

Center(

child: Container(

color: Color.fromARGB(255, 66, 165, 245),

child: new Text("Flutter Cheatsheet"),

),

);

Alignment Property

We use an Alignment Class with the alignment property to be applied for aligning the child widgets.

Alignment take 2 parameters x and y.

Alignment(0.0, 0.0) represents the center of the rectangle.

Center(

child: Container(

color: Color.fromARGB(255, 66, 165, 245),

child: new Text("Flutter Cheatsheet",

style: TextStyle(

fontSize: 10.0

),

),

alignment: Alignment(0.0, 0.0),

),

);

Alignment(-1.0, -1.0) represents the top left of the rectangle.

Alignment(1.0, 1.0) represents the bottom right of the rectangle.

Alignment(0.0, 3.0) represents a point that is horizontally centered with respect to the rectangle and vertically below the bottom of the rectangle by the height of the rectangle.

The below picture show the graph of X and Y

You can also use a constant name with the Alignment Class

Alignment.bottomCenter The center point along the bottom edge same as Alignment(0.0, 1.0)

Alignment.bottomLeft The bottom left corner same as Alignment(-1.0, 1.0)

Alignment.bottomRight The bottom right corner same as Alignment(1.0, 1.0)

Alignment.center The center point, both horizontally and vertically same as Alignment(0.0, 0.0)

Alignment.centerLeft The center point along the left edge same as Alignment(-1.0, 0.0)

Alignment.centerRight The center point along the right edge same as Alignment(1.0, 0.0)

Alignment.topCenter The center point along the top edge same as Alignment(0.0, -1.0)

Alignment.topLeft The top left corner same as Alignment(-1.0, -1.0)