Skip to content

Commit 0033157

Browse files
committed
Added RenderBox? childAt(int index); to FloatColumnChildManager and related changes.
1 parent 45b0b48 commit 0033157

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

lib/src/float_column.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ class _FloatColumnElement extends RenderObjectElement
249249
@override
250250
List<Object> get textAndWidgets => (widget as FloatColumn)._textAndWidgets;
251251

252+
@override
253+
RenderBox? childAt(int index) {
254+
// dmPrint('_FloatColumnElement childAt');
255+
return _childElements[index]?.renderObject as RenderBox?;
256+
}
257+
252258
@override
253259
RenderBox? addOrUpdateChild(int index, {required RenderBox? after}) {
254260
// dmPrint('_FloatColumnElement createChild');

lib/src/float_column_child_manager.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ abstract class FloatColumnChildManager {
99
/// The resulting child widgets, built from `textAndWidgets`.
1010
HashMap<int, Widget?> get childWidgets;
1111

12+
/// Returns the child RenderBox at the given index.
13+
RenderBox? childAt(int index);
14+
1215
/// Adds or updates the child element at the given index.
1316
RenderBox? addOrUpdateChild(int index, {required RenderBox? after});
1417

lib/src/render_float_column_ext.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,17 @@ class _RenderCursor {
472472
index--;
473473
}
474474

475+
/// Jumps to the child at the given index, if it exists.
476+
bool jumpToIndex(int index) {
477+
final newChild = rfc.childManager.childAt(index);
478+
if (newChild == null) return false;
479+
maybeChild = newChild;
480+
previousChild =
481+
(previousChild!.parentData! as FloatColumnParentData).previousSibling;
482+
this.index = index;
483+
return true;
484+
}
485+
475486
/// Updates the current child's widget and associated element.
476487
void updateCurrentChildWidget(Widget widget) {
477488
rfc.childManager.childWidgets[index] = widget;

0 commit comments

Comments
 (0)