Skip to content

[two_dimensional_scrollables] Add alignment to TreeView and TableView#11353

Merged
auto-submit[bot] merged 2 commits intoflutter:mainfrom
Piinks:2d-170349
Mar 25, 2026
Merged

[two_dimensional_scrollables] Add alignment to TreeView and TableView#11353
auto-submit[bot] merged 2 commits intoflutter:mainfrom
Piinks:2d-170349

Conversation

@Piinks
Copy link
Copy Markdown
Contributor

@Piinks Piinks commented Mar 25, 2026

This PR implements declarative alignment for the content of TableView and TreeView widgets when that content is smaller than the viewport extent. Users can now use the alignment property to center or otherwise position the entire table/tree within the viewport.
Alignment correctly reverts to start for axes that exceed viewport dimensions.

Fixes flutter/flutter#170349

  • TableView

    • Added an alignment property of type AlignmentGeometry (defaults to Alignment.topLeft).
    • Full support for both horizontal and vertical alignment.
    • Supports AlignmentDirectional to correctly handle TextDirection (LTR/RTL).
    • Works with pinned rows and columns, as well as reversed axis directions.
  • TreeView

    • Added an alignment property of type AlignmentGeometry (defaults to Alignment.topLeft).
    • Caveat: Currently only supports the vertical component of the alignment. The tree remains
      aligned to the horizontal "start" to maintain consistent indentation logic and avoid layout
      jumps caused by dynamic, lazily-loaded node widths.

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

@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 Mar 25, 2026
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 introduces an alignment property to TableView and TreeView widgets, allowing content to be aligned within the viewport when its extent is smaller than the viewport. The implementation involves adding the alignment property to the widget, viewport, and render object constructors, calculating horizontal and vertical alignment offsets in the render objects, and applying these offsets during layout and painting, considering pinned elements and reversed scroll directions. The package version has been updated to 0.4.0, and new comprehensive tests have been added for both TableView and TreeView to validate the alignment functionality across various scenarios. There is no feedback to provide.

Copy link
Copy Markdown
Contributor

@Hari-07 Hari-07 left a comment

Choose a reason for hiding this comment

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

LGTM, but maybe we can have a test for the default case too? So that the default behaviour does not change unexpectedly in the future

@Piinks
Copy link
Copy Markdown
Contributor Author

Piinks commented Mar 25, 2026

Good call! Thanks! I added the default test cases.

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 25, 2026
@Hari-07 Hari-07 added the CICD Run CI/CD label Mar 25, 2026
@auto-submit auto-submit bot merged commit 0dd2410 into flutter:main Mar 25, 2026
81 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 26, 2026
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Mar 26, 2026
flutter/packages@5909bdd...0dd2410

2026-03-25 katelovett@google.com [two_dimensional_scrollables] Add
alignment to TreeView and TableView (flutter/packages#11353)
2026-03-25 47866232+chunhtai@users.noreply.github.com [ci] Update create
pull request script in github actions (flutter/packages#11350)
2026-03-25 engine-flutter-autoroll@skia.org Manual roll Flutter from
dd64978 to 82d96ef (89 revisions) (flutter/packages#11345)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
okorohelijah pushed a commit to okorohelijah/packages that referenced this pull request Mar 26, 2026
…flutter#11353)

This PR implements declarative alignment for the content of TableView and TreeView widgets when that content is smaller than the viewport extent. Users can now use the alignment property to center or otherwise position the entire table/tree within the viewport.
Alignment correctly reverts to start for axes that exceed viewport dimensions.

Fixes flutter/flutter#170349 

- TableView
   - Added an alignment property of type AlignmentGeometry (defaults to Alignment.topLeft).
   - Full support for both horizontal and vertical alignment.
   - Supports AlignmentDirectional to correctly handle TextDirection (LTR/RTL).
   - Works with pinned rows and columns, as well as reversed axis directions.

- TreeView
   - Added an alignment property of type AlignmentGeometry (defaults to Alignment.topLeft).
   - Caveat: Currently only supports the vertical component of the alignment. The tree remains
     aligned to the horizontal "start" to maintain consistent indentation logic and avoid layout
     jumps caused by dynamic, lazily-loaded node widths.

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). 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.

[^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.
mboetger pushed a commit to mboetger/flutter that referenced this pull request Mar 26, 2026
…r#184198)

flutter/packages@5909bdd...0dd2410

2026-03-25 katelovett@google.com [two_dimensional_scrollables] Add
alignment to TreeView and TableView (flutter/packages#11353)
2026-03-25 47866232+chunhtai@users.noreply.github.com [ci] Update create
pull request script in github actions (flutter/packages#11350)
2026-03-25 engine-flutter-autoroll@skia.org Manual roll Flutter from
dd64978 to 82d96ef (89 revisions) (flutter/packages#11345)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD 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.

[two_dimensional_scrollables/TableView] There's no way to set horizontal/vertical alignment if table fits within view.

2 participants