-
Notifications
You must be signed in to change notification settings - Fork 29.7k
feat: Add mainAxisExtent parameter to GridView constructors
#176927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
There was a problem hiding this 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 adds the mainAxisExtent parameter to the GridView.count and GridView.extent constructors, allowing for more direct control over the main axis extent of grid tiles. The implementation correctly passes this new parameter to the underlying SliverGridDelegate. My main feedback is to add documentation for the new parameter in both constructors to clarify its purpose and its interaction with childAspectRatio, as per the repository's style guide.
| double mainAxisSpacing = 0.0, | ||
| double crossAxisSpacing = 0.0, | ||
| double childAspectRatio = 1.0, | ||
| double? mainAxisExtent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great that you've added the mainAxisExtent parameter. To improve clarity for developers, it would be beneficial to add documentation for this new parameter. The documentation should explain what mainAxisExtent does and clarify its relationship with childAspectRatio (i.e., that mainAxisExtent takes precedence if both are provided).1
This aligns with the style guide's recommendation for documenting all public members.
/// The extent of each tile in the main axis.
///
/// If provided, this value is used as the main-axis extent of each tile.
/// If null, [childAspectRatio] is used instead to determine the main-axis
/// extent.
double? mainAxisExtent,Style Guide References
Footnotes
-
All public members should have documentation. ↩
| double mainAxisSpacing = 0.0, | ||
| double crossAxisSpacing = 0.0, | ||
| double childAspectRatio = 1.0, | ||
| double? mainAxisExtent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the GridView.count constructor, please add documentation for the new mainAxisExtent parameter here as well. It should explain its purpose and its precedence over childAspectRatio.1
/// The extent of each tile in the main axis.
///
/// If provided, this value is used as the main-axis extent of each tile.
/// If null, [childAspectRatio] is used instead to determine the main-axis
/// extent.
double? mainAxisExtent,Style Guide References
Footnotes
-
All public members should have documentation. ↩
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nebkat Can you add a test for this?
victorsanni
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR. Can you add a test to prevent this change from being regressed?
|
Hey @nebkat are you planning to return to this change and add tests? |
|
@Piinks tests added! |
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for coming back and adding tests! It looks like the analyzer is failing currently, can you take a look?
victorsanni
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run dart format packages/flutter/test/widgets/grid_view_test.dart to fix the failing analyzer tests.
3237210 to
0971d36
Compare
|
@nebkat I am going to rebase this to get a fresh test run. There are still some analysis errors here, but we also made some changes to lints last week. Bringing things up to date with a rebase. :) |
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once CI passes. 👍
victorsanni
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nebkat, can you run dart format on all the files in this PR to fix linux analyze?
flutter/flutter@5545bb3...e274574 2025-12-03 [email protected] Roll Skia from 20829e37dfb8 to db4c79d41513 (1 revision) (flutter/flutter#179401) 2025-12-03 [email protected] Roll Skia from adc7ea94cada to 20829e37dfb8 (6 revisions) (flutter/flutter#179385) 2025-12-03 [email protected] Refactor GetShaderClipDepth for clarity (flutter/flutter#179110) 2025-12-03 [email protected] Roll Skia from 3b339a83959b to adc7ea94cada (1 revision) (flutter/flutter#179376) 2025-12-03 [email protected] Roll Dart SDK from eb743a1d4ade to 0bb365d7ac74 (7 revisions) (flutter/flutter#179372) 2025-12-03 [email protected] feat: Add `mainAxisExtent` parameter to `GridView` constructors (flutter/flutter#176927) 2025-12-03 [email protected] Roll Skia from eb01fff20df8 to 3b339a83959b (4 revisions) (flutter/flutter#179371) 2025-12-02 [email protected] Fix crash when text editing value changes between scrolls (flutter/flutter#179163) 2025-12-02 [email protected] Roll Skia from 6bd3b06b1e08 to eb01fff20df8 (3 revisions) (flutter/flutter#179362) 2025-12-02 [email protected] Adds Impellerc flatbuffer format versioning. (flutter/flutter#175470) 2025-12-02 [email protected] Adds format argument to Picture.toImageSync (flutter/flutter#178691) 2025-12-02 [email protected] Delete disabled workflow and add missing permissions key to workflow (flutter/flutter#178911) 2025-12-02 [email protected] [web] Fix some gn warnings (flutter/flutter#178313) 2025-12-02 [email protected] Roll Skia from 45337c4e919d to 6bd3b06b1e08 (4 revisions) (flutter/flutter#179353) 2025-12-02 [email protected] [ios] Reland Dynamic Content Resizing (flutter/flutter#179153) 2025-12-02 [email protected] [web] Fix onTextScaleFactorChanged not getting called. (flutter/flutter#178862) 2025-12-02 [email protected] Roll Packages from c8be05d to 148dcd2 (9 revisions) (flutter/flutter#179343) 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 Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
…ter#176927) Fixes flutter#55290. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. 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](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. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Fixes #55290.
Pre-launch 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-assistbot 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.