SplitPane class
A widget that divides a viewport into two side-by-side or stacked children.
The two child widgets are separated by an interactive divider bar.
Resizing Behavior via Divider Dragging
- When a mouse press occurs on the divider's cell coordinates, the widget enters dragging mode.
- During a mouse drag event, the split pane recalculates the divider position based on the mouse coordinates.
- It clamps the new position to respect the min/max limits of both children.
- Finally, it dynamically mutates the constraints of child1 and child2 in place (e.g. updating a LengthConstraint or PercentageConstraint), causing the layout solver to adjust child viewports on subsequent frames.
Example Usage
SplitPane(
direction: LayoutDirection.horizontal,
dividerChar: '│',
child1: LeftPanel(),
constraint1: const LengthConstraint(20),
child2: RightPanel(),
constraint2: const FlexConstraint(1),
);
Properties and Settings
| Property | Type | Description |
|---|---|---|
child1 |
Widget | The first child widget. |
child2 |
Widget | The second child widget. |
constraint1 |
Constraint | The layout constraint for child1. |
constraint2 |
Constraint | The layout constraint for child2. |
direction |
LayoutDirection | Split direction (horizontal or vertical). |
dividerChar |
String | The character character representing the divider line. |
dividerStyle |
Style | Rendering style attributes for the divider cells. |
Constructors
- SplitPane({required Widget child1, required Widget child2, required Constraint constraint1, required Constraint constraint2, LayoutDirection direction = LayoutDirection.horizontal, String dividerChar = '│', Style dividerStyle = Style.empty})
- Creates a SplitPane widget.
Properties
- child1 → Widget
-
The first child widget.
final
- child2 → Widget
-
The second child widget.
final
- constraint1 ↔ Constraint
-
The layout constraint for child1.
getter/setter pair
- constraint2 ↔ Constraint
-
The layout constraint for child2.
getter/setter pair
- direction → LayoutDirection
-
Split direction (horizontal or vertical).
final
- dividerChar → String
-
The character representing the divider line.
final
- dividerPosition → int
-
Gets the current divider position.
no setter
- dividerStyle → Style
-
Rendering style attributes for the divider cells.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
The optional key for this widget.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → Element -
Creates an Element to manage this widget's location in the tree.
inherited
-
getIntrinsicHeight(
int width) → int -
Computes the intrinsic height of this widget under the given
widthconstraint.inherited -
handleMouseEvent(
MouseEvent event, int localX, int localY) → void - Intercepts mouse drag/press events over the divider.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
Buffer buffer, Rect area) → void -
Renders the widget onto the provided
bufferwithin the specifiedarea.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited