DirectAbsoluteItem class
A widget that positions its child absolutely within a layout container.
AbsoluteItem allows you to position a child widget at specific coordinates relative to its parent's bounds, similar to CSS absolute positioning. The child is removed from the normal document flow and positioned using the top, left, bottom, and right properties.
Usage
LayoutBoxWidget(
children: [
AbsoluteItem(
top: PositionUnit.fixed(20),
left: PositionUnit.fixed(30),
width: SizeUnit.fixed(100),
height: SizeUnit.fixed(50),
child: Container(color: Colors.red),
),
],
)
Positioning
The positioning properties work similarly to CSS:
- top: Distance from the parent's top edge
- left: Distance from the parent's left edge
- bottom: Distance from the parent's bottom edge
- right: Distance from the parent's right edge
You can use any combination of these properties. If both top and bottom are specified, the height is determined by the difference. The same applies to left and right for width.
Sizing
- width and height: Explicit dimensions
- minWidth, maxWidth, minHeight, maxHeight: Size constraints
- aspectRatio: Maintains width/height ratio
Paint Order
The paintOrder property controls the drawing order when multiple absolutely positioned items overlap. Lower values are painted first.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- ProxyWidget
- ParentDataWidget<
LayoutBoxParentData> - DirectAbsoluteItem
- Implemented types
Constructors
- DirectAbsoluteItem.new({Key? key, int? paintOrder, SizeUnit? width, SizeUnit? height, SizeUnit? minWidth, SizeUnit? maxWidth, SizeUnit? minHeight, SizeUnit? maxHeight, PositionUnit? top, PositionUnit? left, PositionUnit? bottom, PositionUnit? right, double? aspectRatio, bool needLayoutBox = false, required Widget child})
-
Creates an absolutely positioned item with the specified properties.
const
Properties
- aspectRatio → double?
-
The aspect ratio constraint (width/height) for this item.
final
- bottom → PositionUnit?
-
The offset from the bottom edge of the parent container.
final
- child → Widget
-
The widget below this widget in the tree.
finalinherited
- debugTypicalAncestorWidgetClass → Type
-
The typical ancestor widget class for this widget.
no setteroverride
- debugTypicalAncestorWidgetDescription → String
-
Describes the RenderObjectWidget that is typically used to set up the
ParentData that applyParentData will write to.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → SizeUnit?
-
The height of the absolutely positioned item.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- left → PositionUnit?
-
The offset from the left edge of the parent container.
final
- maxHeight → SizeUnit?
-
The maximum height constraint for this item.
final
- maxWidth → SizeUnit?
-
The maximum width constraint for this item.
final
- minHeight → SizeUnit?
-
The minimum height constraint for this item.
final
- minWidth → SizeUnit?
-
The minimum width constraint for this item.
final
- needLayoutBox → bool
-
final
- paintOrder → int?
-
The paint order for this absolutely positioned item.
final
- right → PositionUnit?
-
The offset from the right edge of the parent container.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- top → PositionUnit?
-
The offset from the top edge of the parent container.
final
- width → SizeUnit?
-
The width of the absolutely positioned item.
final
Methods
-
applyParentData(
RenderObject renderObject) → void -
Applies the absolute positioning configuration to the child's parent data.
override
-
createElement(
) → ParentDataElement< LayoutBoxParentData> -
Inflates this configuration to a concrete instance.
inherited
-
debugCanApplyOutOfTurn(
) → bool -
Whether the ParentDataElement.applyWidgetOutOfTurn method is allowed
with this widget.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
debugIsValidRenderObject(
RenderObject renderObject) → bool -
Checks if this widget can apply its parent data to the provided
renderObject
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited