-
Notifications
You must be signed in to change notification settings - Fork 29.7k
corrected SliverGridDelegateWithMaxCrossAxisExtent and SliverGridDelegateWithFixedCrossAxisCount mainAxisExtent value #138879
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
corrected SliverGridDelegateWithMaxCrossAxisExtent and SliverGridDelegateWithFixedCrossAxisCount mainAxisExtent value #138879
Conversation
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.
Hi @hello-coder-xu welcome! Thank you for contributing.
| expect(controller.position.pixels, 472.0); | ||
| }); | ||
|
|
||
| testWidgets('SliverGridDelegateWithFixedCrossAxisCount mainAxisExtent corrected', (WidgetTester tester) async { |
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.
Can you add to each of these tests an actual grid of children? I think in the case where childMainAxisExtent is 0 there could be a crash through a divide by zero error in SliverGridRegularTileLayout. This would only become apparent when building the grid. Right now these tests only verify the value of childMainAxisExtent. :)
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 your guidance, I have added it, please check
f6a781f to
f3161c6
Compare
| )); | ||
| expect(tester.takeException(), isNull); | ||
|
|
||
| stateSetter(() => mainAxisExtent = -100); |
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.
I don't think this updates the widget. It just changes the variable value. I would expect a main axis extent of this value would throw an exception since it is not valid.
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.
I updated, please check
| )); | ||
| expect(tester.takeException(), isNull); | ||
|
|
||
| stateSetter(() => mainAxisExtent = -100); |
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.
Same here.
| crossAxisCount: 3, | ||
| mainAxisSpacing: 8, | ||
| crossAxisSpacing: 8, | ||
| mainAxisExtent: -100, |
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.
I think this should probably assert, this does not seem like a valid main axis extent.
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.
I added assertions and adjusted the test cases
…r-xu/flutter into fix/gridview_delegate * 'fix/gridview_delegate' of https://github.com/hello-coder-xu/flutter: (162 commits) add gridview children view fix gridview delegate mainAxisExtent Enable TapRegion to detect all mouse button click (flutter#136799) [flutter_tools] build ios-frameworks: option to exclude plugin frameworks from the build (flutter#129739) Roll Flutter Engine from b87c1b32d55f to eee8aeb953df (1 revision) (flutter#139495) Add Impeller complex layout impeller benchmarks. (flutter#139490) Roll Flutter Engine from cf122461e94a to b87c1b32d55f (3 revisions) (flutter#139491) Remove InkSparkle.constantTurbulenceSeedSplashFactory usage (flutter#139481) Roll Packages from bc72d15 to 5d9874f (9 revisions) (flutter#139480) Roll Flutter Engine from cc9a72b692fc to cf122461e94a (1 revision) (flutter#139468) Roll Flutter Engine from 69cbf87f33c9 to cc9a72b692fc (1 revision) (flutter#139466) Roll Flutter Engine from 05e7f462048b to 69cbf87f33c9 (1 revision) (flutter#139453) Roll Flutter Engine from e782ab139ef2 to 05e7f462048b (1 revision) (flutter#139439) Roll Flutter Engine from 80a2fd76fd64 to e782ab139ef2 (1 revision) (flutter#139437) Roll Flutter Engine from 7ff24be43a36 to 80a2fd76fd64 (1 revision) (flutter#139436) Roll Flutter Engine from cfabe42bc0c6 to 7ff24be43a36 (1 revision) (flutter#139433) Roll Flutter Engine from f0122c32c5cc to cfabe42bc0c6 (1 revision) (flutter#139423) Roll Flutter Engine from f23c33f3831c to f0122c32c5cc (1 revision) (flutter#139422) Roll Flutter Engine from d441f087052c to f23c33f3831c (2 revisions) (flutter#139421) Roll Flutter Engine from 27d37db84b8e to d441f087052c (1 revision) (flutter#139419) ...
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.
Oh my, I just came back to this after the holidays to see I had not submitted my last review. Apologies for the delay here.
| ); | ||
| final double childCrossAxisExtent = usableCrossAxisExtent / crossAxisCount; | ||
| final double childMainAxisExtent = mainAxisExtent ?? childCrossAxisExtent / childAspectRatio; | ||
| final double childMainAxisExtent = math.max( |
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.
Do the tests include a scenario where childMainAxisExtent is calculated to be 0? Later on, this value is used as a denominator in the layout object. Since we are making 0 an explicit option here, we should check that is does not result in a crash later.
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.
Also, if we are now asserting mainAxisExtent is non-negative in the constructor, and it looks like childCrossAxisExtent / childAspectRatio will not be negative, do we need to add the math.max(...) at all?
It won't actually correct the mainAxisExtent as the change/issue describes now, it will just assert as it did in the issue. Can you update the PR to reflect what the expected result is now if we are not correcting the main axis extent?
| this.crossAxisSpacing = 0.0, | ||
| this.childAspectRatio = 1.0, | ||
| this.mainAxisExtent, | ||
| }) : assert(crossAxisCount > 0), |
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.
Can you revert the formatting changes here? This was the proper alignment.
|
(triage) @hello-coder-xu Do you still have plans to come back and address the feedback given above soon-ish? |
|
(triage): I am going to close this since there was no follow-up. Feel free to reopen this if you find the time to work on this again. We also have an issue on file (#138871) to keep track of this. |
fix #138871
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.