Box class
A layout container in the independent layout system.
Box represents a node in the layout tree that can contain children and participate in layout calculations. It implements ParentLayout and provides the foundation for building layout hierarchies independent of Flutter's widget system. Boxes manage their children, handle layout constraints, and coordinate positioning and sizing.
- Mixed-in types
Constructors
-
Box({required LayoutTextDirection textDirection, required LayoutOverflow horizontalOverflow, required LayoutOverflow verticalOverflow, required Layout boxLayout, LayoutData? layoutData, LayoutTextBaseline? textBaseline, double scrollOffsetX = 0.0, double scrollOffsetY = 0.0, List<
Box> ? children, Object? debugKey}) - Creates a box with the specified layout configuration.
Properties
- actualPaintBounds → LayoutRect
-
The actual paint bounds considering clipping from overflow settings.
no setter
- boxLayout ↔ Layout
-
The layout algorithm used to position children of this box.
getter/setter pair
- childCount → int
-
The total number of children in this parent box.
no setter
- constraints → LayoutConstraints
-
The layout constraints applied to this box.
no setter
- contentSize → LayoutSize
-
The total size of all content within this layout.
no setteroverride
- debugKey ↔ Object?
-
Optional debug key for identifying this box during debugging.
getter/setter pair
- firstChild → Box?
-
The first child in the natural children list.
no setter
- firstLayoutChild → ChildLayout?
-
The first child in the layout tree.
no setteroverride
- firstSortedChild → Box?
-
The first child in the sorted children list, or the first natural child if no sorting.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasSize → bool
-
Returns true if this box has been sized.
no setter
- horizontalOverflow ↔ LayoutOverflow
-
How content should be handled when it overflows horizontally.
getter/setter pair
- lastChild → Box?
-
The last child in the natural children list.
no setter
- lastLayoutChild → ChildLayout?
-
The last child in the layout tree.
no setteroverride
- lastSortedChild → Box?
-
The last child in the sorted children list, or the last natural child if no sorting.
no setter
- owner → LayoutPipelineOwner?
-
The layout pipeline owner managing this box's layout lifecycle.
no setter
- paintBounds → LayoutRect
-
The paint bounds of this box from its origin to its size.
no setter
- parent → Box?
-
The parent box of this box, or null if this is the root.
no setter
- parentData ↔ BoxParentData
-
Parent data for this box, storing sibling relationships.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollOffsetX ↔ double
-
The current horizontal scroll offset.
getter/setter pairoverride-getter
- scrollOffsetY ↔ double
-
The current vertical scroll offset.
getter/setter pairoverride-getter
- size ↔ LayoutSize
-
The computed size of this box.
getter/setter pair
- sizedByParent ↔ bool
-
Whether this box determines its own size without input from children.
getter/setter pair
- textBaseline ↔ LayoutTextBaseline?
-
The text baseline to use for layout calculations.
getter/setter pairoverride-getter
- textDirection ↔ LayoutTextDirection
-
The text direction for this layout.
getter/setter pairoverride-getter
- verticalOverflow ↔ LayoutOverflow
-
How content should be handled when it overflows vertically.
getter/setter pair
- viewportSize → LayoutSize
-
The size of the visible viewport.
no setteroverride
Methods
-
addChild(
Box child) → void - Adds a single child to this parent box.
-
addChildren(
List< Box> children) → void - Adds multiple children to this parent box.
-
attach(
LayoutPipelineOwner owner) → void - Attaches this box and all its children to the given layout pipeline owner.
-
defaultComputeDistanceToFirstActualBaseline(
LayoutTextBaseline baseline) → double? - Computes the distance to the first child's baseline.
-
defaultComputeDistanceToHighestActualBaseline(
LayoutTextBaseline baseline) → double? - Computes the distance to the highest baseline among all children.
-
detach(
) → void - Detaches this box and all its children from the layout pipeline.
-
findChildByKey(
Object key) → ChildLayout? -
Finds a child element by its unique key.
override
-
getDistanceToBaseline(
LayoutTextBaseline baseline) → double? - Calculates the distance from the top of the box to its baseline.
-
getDryLayout(
covariant LayoutConstraints constraints) → LayoutSize - Computes the size this box would have under the given constraints without performing actual layout.
-
getFirstDryLayout(
LayoutHandle< Layout> layoutHandle) → ChildLayout? -
Creates a dry layout chain starting from the first child.
override
-
getLastDryLayout(
LayoutHandle< Layout> layoutHandle) → ChildLayout? -
Creates a dry layout chain starting from the last child.
override
-
getMaxIntrinsicHeight(
double width) → double - Computes the maximum height this box could have for the given width.
-
getMaxIntrinsicWidth(
double height) → double - Computes the maximum width this box could have for the given height.
-
getMinIntrinsicHeight(
double width) → double - Computes the minimum height this box could have for the given width.
-
getMinIntrinsicWidth(
double height) → double - Computes the minimum width this box could have for the given height.
-
layout(
LayoutConstraints constraints, {bool parentUsesSize = false}) → void - Lays out this box with the given constraints.
-
markNeedsLayout(
) → void - Marks this box as needing layout.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
performLayout(
) → void - Performs the layout calculation for this box and its children.
-
performResize(
) → void - Computes the size of this box based on its constraints.
-
removeChild(
Box child) → void - Removes a specific child from this parent box.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited