Skip to content

Commit

Permalink
[two_dimensional_scrollables] Fix repaint boundary override in builde…
Browse files Browse the repository at this point in the history
…r delegate (flutter#4814)

Fixes flutter#133582

This fixes a small bug where we accidentally overwrote the default of addRepaintBoundaries

Because of this, I had to refactor a test here that used keys to identify children, but now that an additional render object widget is inserted through the RepaintBoundary, the look-ups broke.
  • Loading branch information
Piinks authored Aug 30, 2023
1 parent b4985e2 commit 64af59e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
4 changes: 4 additions & 0 deletions packages/two_dimensional_scrollables/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.2

* Fixes override of default TwoDimensionalChildBuilderDelegate.addRepaintBoundaries.

## 0.0.1+1

* Adds pub topics to package metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class TableCellBuilderDelegate extends TwoDimensionalChildBuilderDelegate
required int rowCount,
int pinnedColumnCount = 0,
int pinnedRowCount = 0,
super.addRepaintBoundaries = false,
super.addRepaintBoundaries,
required TableViewCellBuilder cellBuilder,
required TableSpanBuilder columnBuilder,
required TableSpanBuilder rowBuilder,
Expand Down
2 changes: 1 addition & 1 deletion packages/two_dimensional_scrollables/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: two_dimensional_scrollables
description: Widgets that scroll using the two dimensional scrolling foundation.
version: 0.0.1+1
version: 0.0.2
repository: https://github.com/flutter/packages/tree/main/packages/two_dimensional_scrollables
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+two_dimensional_scrollables%22+

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ void main() {
expect(delegate.maxXIndex, 4); // columns
});

test('Respects super class default for addRepaintBoundaries', () {
final TableCellBuilderDelegate delegate = TableCellBuilderDelegate(
cellBuilder: (_, __) => cell,
columnBuilder: (_) => span,
rowBuilder: (_) => span,
columnCount: 5,
rowCount: 6,
);
expect(delegate.addRepaintBoundaries, isTrue);
});

test('Notifies listeners & rebuilds', () {
int notified = 0;
TableCellBuilderDelegate oldDelegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,24 +287,17 @@ void main() {
expect(viewport.mainAxis, Axis.vertical);
// first child
TableVicinity vicinity = const TableVicinity(column: 0, row: 0);
expect(
parentDataOf(viewport.firstChild!).vicinity,
vicinity,
);
TableViewParentData parentData = parentDataOf(
tester.renderObject<RenderBox>(find.byKey(childKeys[vicinity]!)),
viewport.firstChild!,
);
expect(parentData.vicinity, vicinity);
expect(parentData.layoutOffset, Offset.zero);
expect(parentData.isVisible, isTrue);
// after first child
vicinity = const TableVicinity(column: 1, row: 0);
expect(
parentDataOf(viewport.childAfter(viewport.firstChild!)!).vicinity,
vicinity,
);

parentData = parentDataOf(
tester.renderObject<RenderBox>(find.byKey(childKeys[vicinity]!)),
viewport.childAfter(viewport.firstChild!)!,
);
expect(parentData.vicinity, vicinity);
expect(parentData.layoutOffset, const Offset(200, 0.0));
Expand All @@ -317,13 +310,7 @@ void main() {

// last child
vicinity = const TableVicinity(column: 4, row: 4);
expect(
parentDataOf(viewport.lastChild!).vicinity,
vicinity,
);
parentData = parentDataOf(
tester.renderObject<RenderBox>(find.byKey(childKeys[vicinity]!)),
);
parentData = parentDataOf(viewport.lastChild!);
expect(parentData.vicinity, vicinity);
expect(parentData.layoutOffset, const Offset(800.0, 800.0));
expect(parentData.isVisible, isFalse);
Expand All @@ -334,12 +321,8 @@ void main() {
);
// before last child
vicinity = const TableVicinity(column: 3, row: 4);
expect(
parentDataOf(viewport.childBefore(viewport.lastChild!)!).vicinity,
vicinity,
);
parentData = parentDataOf(
tester.renderObject<RenderBox>(find.byKey(childKeys[vicinity]!)),
viewport.childBefore(viewport.lastChild!)!,
);
expect(parentData.vicinity, vicinity);
expect(parentData.layoutOffset, const Offset(600.0, 800.0));
Expand Down

0 comments on commit 64af59e

Please sign in to comment.