AlignedWidgetExtension extension

Extension methods for Widget that provide convenient alignment functionality.

This extension adds methods to easily wrap widgets in Align widgets with various alignment options. All methods return new Align widgets without modifying the original widget.

The Align widget positions its child within itself according to the specified alignment. It can also optionally size itself based on the child's size using width and height factors.

Alignment Options:

  • Center: center, alignCenter()
  • Edges: centerLeft, centerRight, topCenter, bottomCenter
  • Corners: topLeft, topRight, bottomLeft, bottomRight

Size Factors:

  • widthFactor: If non-null, sets width to child's width × factor
  • heightFactor: If non-null, sets height to child's height × factor
  • If both are null, the Align widget takes up all available space

Example usage:

Text('Hello World')
  .alignTopRight() // Aligns text to top-right corner
  .sizedBox(width: 200, height: 100);
on

Methods

align({AlignmentGeometry alignment = Alignment.center, double? widthFactor, double? heightFactor}) Align

Available on Widget, provided by the AlignedWidgetExtension extension

Wraps the widget in an Align widget with the specified alignment.
alignBottomCenter({double? widthFactor, double? heightFactor}) Align

Available on Widget, provided by the AlignedWidgetExtension extension

Aligns the widget to the bottom-center of the available space.
alignBottomLeft({double? widthFactor, double? heightFactor}) Align

Available on Widget, provided by the AlignedWidgetExtension extension

Aligns the widget to the bottom-left corner of the available space.
alignBottomRight({double? widthFactor, double? heightFactor}) Align

Available on Widget, provided by the AlignedWidgetExtension extension

Aligns the widget to the bottom-right corner of the available space.
alignCenter({double? widthFactor, double? heightFactor}) Align

Available on Widget, provided by the AlignedWidgetExtension extension

Aligns the widget to the center of the available space.
alignCenterLeft({double? widthFactor, double? heightFactor}) Align

Available on Widget, provided by the AlignedWidgetExtension extension

Aligns the widget to the center-left of the available space.
alignCenterRight({double? widthFactor, double? heightFactor}) Align

Available on Widget, provided by the AlignedWidgetExtension extension

Aligns the widget to the center-right of the available space.
alignTopCenter({double? widthFactor, double? heightFactor}) Align

Available on Widget, provided by the AlignedWidgetExtension extension

Aligns the widget to the top-center of the available space.
alignTopLeft({double? widthFactor, double? heightFactor}) Align

Available on Widget, provided by the AlignedWidgetExtension extension

Aligns the widget to the top-left corner of the available space.
alignTopRight({double? widthFactor, double? heightFactor}) Align

Available on Widget, provided by the AlignedWidgetExtension extension

Aligns the widget to the top-right corner of the available space.