PositionedWidgetExtensions extension

Extension methods for Widget that provide convenient positioning functionality within Stack widgets.

This extension adds methods to easily wrap widgets in Positioned widgets for precise positioning within Stack layouts. All methods return new Positioned widgets without modifying the original widget.

The extension provides both comprehensive positioning control (positioned) and convenient shortcuts for individual edge positioning (positionedTop, positionedLeft, etc.).

Important: Positioned widgets can only be used as direct children of Stack widgets. Using them outside of a Stack will cause a runtime error.

Example usage:

Stack(
  children: [
    Container(color: Colors.blue).positioned(left: 10, top: 20),
    Text('Overlay').positionedTop(50).positionedRight(30),
  ],
);
on

Methods

positioned({double? left, double? top, double? right, double? bottom, double? width, double? height}) Positioned

Available on Widget, provided by the PositionedWidgetExtensions extension

Wraps the widget in a Positioned widget with the specified positioning constraints.
positionedBottom(double bottom) Positioned

Available on Widget, provided by the PositionedWidgetExtensions extension

Positions the widget at a specific distance from the bottom edge of the stack.
positionedHeight(double height) Positioned

Available on Widget, provided by the PositionedWidgetExtensions extension

Constrains the widget to a specific height within the stack.
positionedLeft(double left) Positioned

Available on Widget, provided by the PositionedWidgetExtensions extension

Positions the widget at a specific distance from the left edge of the stack.
positionedRight(double right) Positioned

Available on Widget, provided by the PositionedWidgetExtensions extension

Positions the widget at a specific distance from the right edge of the stack.
positionedTop(double top) Positioned

Available on Widget, provided by the PositionedWidgetExtensions extension

Positions the widget at a specific distance from the top edge of the stack.
positionedWidth(double width) Positioned

Available on Widget, provided by the PositionedWidgetExtensions extension

Constrains the widget to a specific width within the stack.