-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Implement Router widget and widgets app api #60299
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
Implement Router widget and widgets app api #60299
Conversation
ea1e776 to
df72c94
Compare
43dca20 to
25630c6
Compare
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.
@mdebbar @goderbauer as we discussed before, we want to have an api to force create a browser history entry or not.
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.
Having a boolean as an argument after the callback makes it hard to read. I suggest either splitting into two methods or move the boolean argument before the callback.
852af70 to
e571129
Compare
|
a friendly bump |
|
FWIW, it's hard for me to evaluate the API really without the stocks app migration as well. |
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.
nit: "if we use"
|
We should convert it to use the standard codec, if we can. I just don't want to be adding any more places where we're converting data to JSON, it's highly inefficient. |
e8dec5b to
824d8f3
Compare
|
@Hixie I opened a separate issue about converting navigation channel #63121 in the meanwhile, I addressed all other comments. This pr is ready for another look @goderbauer and @Hixie |
41afc9e to
8c54425
Compare
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.
@goderbauer
we have to do this check because method channel invoke method will throw if there is no corresponding listener on the engine side.
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.
Should the navigator channel be an OptionalMethodChannel to avoid that problem?
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 have to reuse the old method until the engine side method is in place otherwise it will throw an exception.
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.
Instead of duplication the code, forward the call to routeUpdated?
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.
Just some minor comments.
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.
... are stored ...
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.
Should the navigator channel be an OptionalMethodChannel to avoid that problem?
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.
nit: space between if and (.
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 blow.
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 remove the else? Same above.
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 shouldn't be typed "Object". Maybe take everything that's in the map as named arguments?
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.
Instead of duplication the code, forward the call to routeUpdated?
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.
Make these named arguments?
|
Looks like there are some doc errors. The StandartMessageCodec/JSON question aside, this LGTM. |
b642cf6 to
9a2d2fd
Compare
9a2d2fd to
0b113e9
Compare
| @@ -1,41 +0,0 @@ | |||
| // Copyright 2014 The Flutter Authors. All rights reserved. | |||
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 realized we are not exposing this api in the package level, we should be good to remove this without a breaking change
|
addressed all comments, and also updated the stock app rewrite pr https://github.com/chunhtai/flutter/pull/2/files |
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
| Widget routing; | ||
| if (_usesRouter) { | ||
| assert(_effectiveRouteInformationProvider != null); | ||
| routing = Router<dynamic>( |
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 missed that we were creating this with dynamic as the type here. That seems to defeat the purpose of having a T type argument on Router...
Not sure what the right answer is, but we should probably find a better solution than defining the API with T then ignoring it.
(I noticed this because we're changing dynamic to Object as part of the NNBD transition.)
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 was struggling hard on this one too, you can not set T for a single constructor, and it is weird to define on the class level because non router constructor does not care. we could separate out router constructor to a class or method on its own, but that seems to add a whole lot of complexity to the code. For now, it will let you initialize with different type of route information parser and router delegate, but it will throw on build
Description
Introduce router widget and widgets app api, I will include the stock app rewrite in a separate pr once we agree on the api details
stock app rewrite draft chunhtai#2
Related Issues
#45938
Tests
I added the following tests:
See files
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.