Skip to content

Conversation

@chunhtai
Copy link
Contributor

#99121

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels. labels Apr 22, 2022
@chunhtai chunhtai requested a review from goderbauer April 22, 2022 23:59
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document the context argument?

Also: If I use this context to create a dependency, is it guaranteed that parseRouteInformation is called again when that dependency changes? (please add a test that demonstrates this and prevents us from breaking this in the future). If parseRouteInformation is not called again, this could be confusing since whatever parseRouteInformation returned may now be outdated...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should not reparse in this case, the parsing method is called when user enter a new url, and this change is to make sure the parsing can depend on the state of the app at that moment. If state has change that the current navigator stack need to be rebuild, it will be customer's job to re-trigger the parsing. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds odd to me that the parsing depends on something that can change, but if it changes that's just ignored? So we have a use case where looking something up in the tree like this is needed to do the parsing?

Also, looking up something will create a dependency between the build context and the inherited widget. So something will rebuild (unnecessarily) if the dependency changes...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is enable go_router redirect with buildcontext #99121, but I think the idea is the same.

To me, I can't imagine a reparsing the url when dependencies change can be useful, but I left a comment on the issue to see how people think about it.

The unnecessarily rebuild is troubling me a bit as well, I think I can modify the inheritance logic a bit to not link during the parsing, but it seems very hacky.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked to @johnpryan offline, we decide to make Router to reparse the route information if the dependencies update. If user only want to look up the dependency without trigger rebuild automatically, they can use getElementForInheritedWidgetOfExactType instead

@chunhtai chunhtai force-pushed the issues/99121-buildcontext branch from 89be3d6 to dada980 Compare April 27, 2022 20:56
@chunhtai chunhtai force-pushed the issues/99121-buildcontext branch from dada980 to 262fcb9 Compare April 27, 2022 23:05
@chunhtai chunhtai changed the title Add buildcontext to RouteInformationParser.parseRouteInformation Add RouteInformationParser.parseRouteInformationWithDependencies Apr 27, 2022
@chunhtai chunhtai requested a review from goderbauer April 27, 2022 23:28
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants