-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Feat: Add readFrom method to ModalRoute #164684
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
base: master
Are you sure you want to change the base?
Conversation
3100adb to
e900d4b
Compare
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.
This approach makes sense but we might be setting a precedent here about how to access a value from an InheritedWidget/Model without subscribing, so I want to make sure we get it right. See my comment about the option of making _ModalScopeStatus public.
| /// * [of], which provides the same information but will cause rebuilds when | ||
| /// the route changes. | ||
| static ModalRoute<T>? readFrom<T extends Object?>(BuildContext context) { | ||
| return context.getInheritedWidgetOfExactType<_ModalScopeStatus>()?.route as ModalRoute<T>?; |
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.
If we made _ModalScopeStatus public would that also solve the problem? I'm not sure whether that's a good idea, just thinking this through.
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.
Yes, I think making _ModalScopeStatus public would solve the problem, but i don't know reasoning behind why this was made private at first place.
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.
Just an idea, in #165289 I am planning to migrate Theme subscribing to selector pattern. So, if we start following that same pattern everywhere, we may have 2 methods for subscription and for read. WDYT ?
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 just left another review over on that PR. I'm really liking that approach but still thinking through the Object? types that end up all over. Maybe we should finish that PR first and then come back to this one?
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.
Yup, make sense.
| // Should just build page 2. | ||
| expect(log, <String>['building page 2']); | ||
| log.clear(); | ||
| }); |
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.
Indeed this fails when using ModalRoute.of 👍
|
Hi, any plans to complete this PR? |
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 coming back to this now. Some things we should decide before committing to this:
- This is a big precedent for when methods create dependencies or not, so we should think this through and get the naming right. Related: #169539. A discussion on
ofmethods and whether or not they should create dependencies. - Is the alternative of making _ModalScopeStatus public viable?
Overall I think this is a problem we should probably solve though, since there is no way around the fact that _ModalScopeStatus is private now.
|
@justinmc I am not sure, why _ModalScopeStatus was made private in first place ? If that can be public that we should go on that path. |
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.
@chunhtai @dkwingsmt Do you guys have any thoughts on whether we should add a non-subscribing method here versus making _ModalScopeStatus public? I'm leaning the latter. This relates to your discussion in #169539.
|
I prefer having non-subscribing methods over publicizing inherited classes such as
|
|
In general I'm in favor of this PR. My only concern is the name, since, again, we're setting a precedence for all such methods. I consulted a few AIs and I picked the following suggestions:
|
|
Also agree to @dkwingsmt 's point, though instead of adding a new API, I think we should standarize this and use createdependencies bool https://api.flutter.dev/flutter/widgets/Focus/of.html |
|
@chunhtai There was a discussion in #169539 (comment), where @davidhicks980 said that an optional parameter |
|
Thanks for the link, I will continue the discussion in the issue |
|
Greetings from stale PR triage! 👋 |
|
Is this still waiting on #169539? |
|
I think we haven't really made up our mind to make a decision for #169539. Maybe I can host a dash forum for this. |
@dkwingsmt did we came up with some conclusion on this? |
|
Yeah. Sorry I haven't had time, although I did plan to write a design doc for it, maybe within the next weeks. |
Cool cool, take your time. |
Feat: Add readFrom method to ModalRoute
fixes: #163467
Pre-launch Checklist
///).