Skip to content

[two_dimensional_scrollables] Activate leak testing and fix memory leaks#11653

Open
ValentinVignal wants to merge 7 commits intoflutter:mainfrom
ValentinVignal:tow-dimensional-scrollables/fix-memory-leaks
Open

[two_dimensional_scrollables] Activate leak testing and fix memory leaks#11653
ValentinVignal wants to merge 7 commits intoflutter:mainfrom
ValentinVignal:tow-dimensional-scrollables/fix-memory-leaks

Conversation

@ValentinVignal
Copy link
Copy Markdown
Contributor

The package manipulates disposable objects. This PR activates leak testing to make sure disposable objects are correctly disposed.

It also fixes the memory leak warnings from the tests

See the documentation: https://github.com/dart-lang/leak_tracker/blob/main/doc%2Fleak_tracking%2FDETECT.md

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 6, 2026
@ValentinVignal ValentinVignal requested a review from Piinks May 6, 2026 09:32
@ValentinVignal
Copy link
Copy Markdown
Contributor Author

cc @polina-c

@github-actions github-actions Bot added p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package triage-framework Should be looked at in framework triage labels May 6, 2026
Comment on lines +149 to +151
static Widget builder({
Key? key,
bool? primary,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether that is okay to change from a constructor to a static method. Would you have a better design in mind?

Comment on lines +2042 to +2045
'merged column that exceeds metrics will assert',
// The build throws an assertion error which prevents the table from
// properly disposing the elements.
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it acceptable to have memory leaks when the build asserts?

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the two_dimensional_scrollables package to version 0.5.2, focusing on resolving memory leaks by refactoring TableView and TreeView to properly manage the lifecycle of their delegates and animations. It introduces leak_tracker_flutter_testing to the test suite and updates existing tests to ensure proper resource disposal. Review feedback identified several critical issues: missing parameter propagation in the new _TableViewBuilder and _TableViewList widgets, a missing didUpdateWidget implementation in _TableViewListState, and concerns regarding the breaking nature of converting constructors to static methods.

Comment thread packages/two_dimensional_scrollables/lib/src/table_view/table.dart
Comment thread packages/two_dimensional_scrollables/lib/src/table_view/table.dart
Comment thread packages/two_dimensional_scrollables/lib/src/table_view/table.dart
super.dragStartBehavior,
super.keyboardDismissBehavior,
super.clipBehavior,
static Widget builder({
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Changing TableView.builder from a constructor to a static method that returns a Widget is a breaking change. This changes the return type from TableView to Widget, which may break existing code that relies on the specific type or uses it in a context where a TableView instance is expected. Since this is a patch version bump (0.5.1 to 0.5.2), breaking changes should generally be avoided. Consider if a minor version bump is more appropriate or if there is a non-breaking way to manage the delegate's lifecycle.

@github-actions github-actions Bot removed the CICD Run CI/CD label May 6, 2026
),
)
: TableView.builder(
key: ValueKey(_selectionMode),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm doing this to force the widget to rebuild (and re-run _buildCell). Because now, when we toggle from "Single-cell" to "Disable" selection, the delegate doesn't change, and _buildCell is not rebuilt. That makes the test Selection SegmentedButton control works in packages/two_dimensional_scrollables/example/test/table_view/simple_table_test.dart:60 fail.

Ideally, I think we'd need some kind of notifier that the widget built in _buildCell would listen to. But since it is only an example, I'd thought this would be enough?

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package triage-framework Should be looked at in framework triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant