alignCenter method

Align alignCenter({
  1. double? widthFactor,
  2. double? heightFactor,
})

Aligns the widget to the center of the available space.

This is a convenience method equivalent to calling align(alignment: Alignment.center). Centers the widget both horizontally and vertically within the available space.

Parameters:

  • widthFactor: If non-null, sets the width to the child's width multiplied by this factor. If null, takes up all available width.
  • heightFactor: If non-null, sets the height to the child's height multiplied by this factor. If null, takes up all available height.

Returns an Align widget with center alignment.

Example:

Text('Centered text')
  .alignCenter()
  .sizedBox(width: 200, height: 100);

Implementation

Align alignCenter({
  double? widthFactor,
  double? heightFactor,
}) =>
    align(
      alignment: Alignment.center,
      widthFactor: widthFactor,
      heightFactor: heightFactor,
    );