![]() |
VOOZH | about |
Center widget comes built-in with flutter, it aligns its child widget to the center of the available space on the screen. The size of this widget will be as big as possible if the widthFactor and heightFactor properties are set to null and the dimensions are constrained. And in case the dimensions are not constrained and the widthFactor and HeightFactor are set to null then the Center widget takes the size of its child widget. Let's understand this with the help of examples.
Syntax:
Center({Key key,
double widthFactor,
double heightFactor,
Widget child})Example:
The main.dart file.
Output:
When the above code is executed, the output is shown below:
👁 center align widgetIf the properties are defined as below:
heightFactor: 3,
The following design changes can be observed:
👁 center top align widgetIf the properties are defined as below:
widthFactor: 1,
The following design changes can be observed:
👁 ImageIf the properties are defined as below:
heightFactor: 3, widthFactor: 0.8,
The following design changes can be observed:
👁 Image