-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add optional axis specifier to static scrollable methods #124894
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
|
Some checks are unhappy 😄 |
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 we need to adjust the error message below to indicate that maybe there was a scrollable in the context, it just didn't have the right axis?
de147dd to
9cf8a1e
Compare
goderbauer
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
| if (context != originalContext) { | ||
| // Establish the dependency on the correct context. | ||
| // Get the element. | ||
| final InheritedElement element = context.getElementForInheritedWidgetOfExactType<_ScrollableScope>()!; |
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.
To consider: I think I would find this code a little cleaner if you remove the getInheritedWidgetOfExactType calls altogether and instead replace them with getElementForInheritedWidgetOfExactType. From there you can access the scrollable via element.widget.scrollable (probably needs a cast). IMO, it makes it a little clearer that the element you depend on is the one you checked the axis on. Right now, it look a little like you look up one inherited widget, check something on it, and then look up another widget to depend on. (sure, in the end you look up the same thing, but it could be made explicit).
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.
Maybe simplify further and remove the branching. The code inside the if is also correct when context == originalContext, right?
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.
Ok! Will do, that would definitely be cleaner
|
auto label is removed for flutter/flutter, pr: 124894, due to - The status or check suite Windows framework_tests_misc has failed. Please fix the issues identified (or deflake) before re-applying this label. |
flutter/flutter@15cb1f8...42fb0b2 2023-04-18 [email protected] Fix text theme dart fix cases (flutter/flutter#125052) 2023-04-18 [email protected] Update the copy icon in snippets and samples to use the standard one (flutter/flutter#123651) 2023-04-18 [email protected] Remove unused context parameter (flutter/flutter#124254) 2023-04-18 [email protected] iOS spell check cursor placement (flutter/flutter#124875) 2023-04-18 [email protected] Roll Flutter Engine from d2973619074e to 55bb065c607b (1 revision) (flutter/flutter#125047) 2023-04-18 [email protected] Stop running "_impeller_" benchmark variants (flutter/flutter#125044) 2023-04-18 [email protected] Roll Packages from 0277f2a to faf53fb (7 revisions) (flutter/flutter#125040) 2023-04-18 [email protected] Roll Flutter Engine from c4396f9f602f to d2973619074e (6 revisions) (flutter/flutter#125039) 2023-04-18 [email protected] Roll pub packages (flutter/flutter#125005) 2023-04-18 [email protected] [InputDatePickerFormField] adds acceptEmptyDate to InputDatePickerFormField Widget (flutter/flutter#124143) 2023-04-18 [email protected] relayout active ListWheelScrollView children every performLayout (flutter/flutter#124476) 2023-04-18 [email protected] Roll Flutter Engine from 4a603aaff32e to c4396f9f602f (2 revisions) (flutter/flutter#125007) 2023-04-18 [email protected] Roll Flutter Engine from 20034a8d62c4 to 4a603aaff32e (2 revisions) (flutter/flutter#125004) 2023-04-18 [email protected] Add optional axis specifier to static scrollable methods (flutter/flutter#124894) 2023-04-17 [email protected] Update usage of standalone`pub` executable in flutter_tools testing docs (flutter/flutter#124898) 2023-04-17 [email protected] Add Harish Anbalagan to AUTHORS (flutter/flutter#124684) 2023-04-17 [email protected] Roll Flutter Engine from b2d07388ceb6 to 20034a8d62c4 (7 revisions) (flutter/flutter#125001) 2023-04-17 [email protected] Add an example for SearchBar (flutter/flutter#124992) 2023-04-17 [email protected] SelectionContainer's listeners can remove itself during listener call� (flutter/flutter#124624) 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],[email protected],[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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/flutter@15cb1f8...42fb0b2 2023-04-18 [email protected] Fix text theme dart fix cases (flutter/flutter#125052) 2023-04-18 [email protected] Update the copy icon in snippets and samples to use the standard one (flutter/flutter#123651) 2023-04-18 [email protected] Remove unused context parameter (flutter/flutter#124254) 2023-04-18 [email protected] iOS spell check cursor placement (flutter/flutter#124875) 2023-04-18 [email protected] Roll Flutter Engine from d2973619074e to 55bb065c607b (1 revision) (flutter/flutter#125047) 2023-04-18 [email protected] Stop running "_impeller_" benchmark variants (flutter/flutter#125044) 2023-04-18 [email protected] Roll Packages from 0277f2a to faf53fb (7 revisions) (flutter/flutter#125040) 2023-04-18 [email protected] Roll Flutter Engine from c4396f9f602f to d2973619074e (6 revisions) (flutter/flutter#125039) 2023-04-18 [email protected] Roll pub packages (flutter/flutter#125005) 2023-04-18 [email protected] [InputDatePickerFormField] adds acceptEmptyDate to InputDatePickerFormField Widget (flutter/flutter#124143) 2023-04-18 [email protected] relayout active ListWheelScrollView children every performLayout (flutter/flutter#124476) 2023-04-18 [email protected] Roll Flutter Engine from 4a603aaff32e to c4396f9f602f (2 revisions) (flutter/flutter#125007) 2023-04-18 [email protected] Roll Flutter Engine from 20034a8d62c4 to 4a603aaff32e (2 revisions) (flutter/flutter#125004) 2023-04-18 [email protected] Add optional axis specifier to static scrollable methods (flutter/flutter#124894) 2023-04-17 [email protected] Update usage of standalone`pub` executable in flutter_tools testing docs (flutter/flutter#124898) 2023-04-17 [email protected] Add Harish Anbalagan to AUTHORS (flutter/flutter#124684) 2023-04-17 [email protected] Roll Flutter Engine from b2d07388ceb6 to 20034a8d62c4 (7 revisions) (flutter/flutter#125001) 2023-04-17 [email protected] Add an example for SearchBar (flutter/flutter#124992) 2023-04-17 [email protected] SelectionContainer's listeners can remove itself during listener call� (flutter/flutter#124624) 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],[email protected],[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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This is motivated by part of the 2D scrolling proposal: flutter.dev/go/2D-Foundation
This is one of the last little PRs to prep for the 2D scrolling foundation.
This adds an optional
axisparameter to the static Scrollable methods[of, maybeOf, recommendDeferredLoadingForContext]. This allows developers that are nesting scrollables (or one day using 2D scrolling) to look them up instead by a particular axis.In general, even outside the context of 2D, I think this is helpful. I am often asked how to get the outer scrollable when nesting. Now it can be done.
There is also a small semantic refactor here in ScrollableState.build, this just creates a private method (_buildChrome) that will be overridden in 2D later. It is easier to add now than in the really big PR that will be.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.