LayoutBoxWidget class
A flexible layout container that supports scrolling and custom layout algorithms.
LayoutBox is a fundamental building block for creating custom layouts in Flutter. It provides scrolling capabilities, overflow handling, and integrates with custom layout algorithms through the Layout interface.
Basic Usage
LayoutBoxWidget(
layout: FlexLayout(
direction: FlexDirection.row,
alignItems: BoxAlignmentGeometry.center,
),
children: [
Text('Item 1'),
Text('Item 2'),
],
)
Scrolling
LayoutBox automatically provides scrolling when content overflows:
- horizontalOverflow and verticalOverflow control scroll behavior
- horizontalController and verticalController allow programmatic scrolling
- diagonalDragBehavior controls how diagonal gestures are interpreted
Layout Algorithms
The layout property defines how children are positioned and sized. Built-in layouts include FlexLayout for flexbox behavior, but custom layouts can be implemented by extending the Layout class.
Text Direction
The textDirection property affects directional alignments and scrolling. If null, it uses the ambient Directionality from the widget tree.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- LayoutBoxWidget
Constructors
-
LayoutBoxWidget.new({Key? key, TextDirection? textDirection, bool reversePaint = false, LayoutOverflow horizontalOverflow = LayoutOverflow.visible, LayoutOverflow verticalOverflow = LayoutOverflow.visible, ScrollController? horizontalController, ScrollController? verticalController, DiagonalDragBehavior diagonalDragBehavior = DiagonalDragBehavior.free, Axis mainScrollDirection = Axis.vertical, TextBaseline? textBaseline, BorderRadiusGeometry? borderRadius, Clip clipBehavior = Clip.hardEdge, bool reverseHorizontalScroll = false, bool reverseVerticalScroll = false, required Layout layout, required List<
Widget> children}) -
Creates a layout container with the specified properties.
const
Properties
- borderRadius → BorderRadiusGeometry?
-
The border radius applied to the container's background and clipping.
final
-
children
→ List<
Widget> -
The list of child widgets to layout.
final
- clipBehavior → Clip
-
How to clip content that extends beyond the container bounds.
final
- diagonalDragBehavior → DiagonalDragBehavior
-
Controls how diagonal drag gestures are interpreted.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- horizontalController → ScrollController?
-
Controller for horizontal scrolling.
final
- horizontalOverflow → LayoutOverflow
-
How to handle content that exceeds horizontal bounds.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- layout → Layout
-
The layout algorithm to use for positioning and sizing children.
final
- mainScrollDirection → Axis
-
The primary scrolling axis for layout optimizations.
final
- reverseHorizontalScroll → bool
-
final
- reversePaint → bool
-
Whether to reverse the paint order of children.
final
- reverseVerticalScroll → bool
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- textBaseline → TextBaseline?
-
The text baseline to use for text alignment.
final
- textDirection → TextDirection?
-
The text direction for resolving directional layout properties.
final
- verticalController → ScrollController?
-
Controller for vertical scrolling.
final
- verticalOverflow → LayoutOverflow
-
How to handle content that exceeds vertical bounds.
final
Methods
-
build(
BuildContext context) → Widget -
Builds the widget tree for this layout container.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
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
-
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