Skip to content

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Apr 27, 2022

This change will break the following:

  1. customer will need to also pass in the goRouter.routeInfromationProvider.
  2. GoRouterDelegate.namedLocation is move to GoRouteInfromationParser.namedLocation

breaking change doc flutter.dev/go/go-router-v4-breaking-changes

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 relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • 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.

@chunhtai chunhtai force-pushed the issues/99121-refactor branch 2 times, most recently from 7331b08 to ea2eb4f Compare May 6, 2022 20:55
@chunhtai chunhtai requested a review from johnpryan May 13, 2022 20:32
@chunhtai chunhtai force-pushed the issues/99121-refactor branch from 3081965 to be0f48a Compare May 16, 2022 22:29
Copy link
Contributor

@johnpryan johnpryan left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +23 to +24
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think you can use this type directly as long as we set the Dart SDK constraint to >=2.17.0 <3.0.0

Suggested change
// ignore: unnecessary_non_null_assertion
static WidgetsBinding get _binding => WidgetsBinding.instance!;
static WidgetsBinding get _binding => WidgetsBinding.instance;

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 the cirrus still use 2.16.xx, I can skip it but I think it is probably better to keep this so that it can still be analyzed

Copy link
Contributor

Choose a reason for hiding this comment

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

Why does selectMultiEntryHistory() need to be called? The docs say it's the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there is another MateriaApp wraps on top, it may have switched to single entry history.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add a comment:

Suggested change
final bool replace = type == RouteInformationReportingType.neglect ||
// Avoid adding a new history entry if the route is the same as before.
final bool replace = type == RouteInformationReportingType.neglect ||

Copy link
Contributor

Choose a reason for hiding this comment

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

Was this removed because it was unused? I see that namedLocation moved from GoRouterDelegate into GoRouteInformationParser, but I don't see what happened to this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes i moved the functionality to goRouteInformationParser, GoRouteMatch is not exposed to the package level

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@johnpryan johnpryan May 23, 2022

Choose a reason for hiding this comment

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

It doesn't look like there are any tests for this method - I'll probably add some when I start working on flutter/flutter#99126

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 method should be covered by a lot of test indirectly, any test that build the page from uri should do

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but I think it's important enough to have it's own set of tests eventually.

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 can add it in this patch

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it's helpful, but there's some test cases in this file that might be useful to consider: https://github.com/johnpryan/tree_router/blob/main/test/tree_test.dart

@johnpryan
Copy link
Contributor

It looks like there's still some analyzer warnings:

Running command: "dart analyze --fatal-infos" in /tmp/cirrus-ci-build/packages/go_router
Analyzing go_router...

   info - lib/src/go_route_information_parser.dart:374:25 - Separate the control structure expression from its statement. - always_put_control_body_on_new_line
   info - test/go_route_information_parser_test.dart:141:42 - This function has a nullable return type of 'String?', but ends without returning a value. Try adding a return statement, or if no value is ever returned, try changing the return type to 'void'. - body_might_complete_normally_nullable
   info - test/go_route_information_parser_test.dart:142:50 - Separate the control structure expression from its statement. - always_put_control_body_on_new_line

@chunhtai chunhtai force-pushed the issues/99121-refactor branch from 2a907cf to 2a293bb Compare May 27, 2022 23:32
@stuartmorgan-g
Copy link
Collaborator

Please make sure flutter/flutter#105150 (comment) is addressed before this is re-landed in any form (or any other changes are landed to go_router, ideally).

@johnpryan
Copy link
Contributor

Would it be acceptable to combine this with #2177? If I understand correctly, as long as both packages are touched in go_router and go_router_builder, everything will be tested properly in presubmit.

cc: @kevmoo

@johnpryan
Copy link
Contributor

It sounds like the better option is to combine go_router_builder and go_router into a single package?

@stuartmorgan-g
Copy link
Collaborator

Would it be acceptable to combine this with #2177? If I understand correctly, as long as both packages are touched in go_router and go_router_builder, everything will be tested properly in presubmit.

That would fix the problem in this particular instance, but leave the fundamental problem that makes changing go_router unsafe unaddressed. I would much rather we not leave landmines in the CI.

It sounds like the better option is to combine go_router_builder and go_router into a single package?

I don't know the details of these packages, but I'm unclear as to why the solution isn't just to have a normal, pub-based dependency on go_router from the other package's example.

@johnpryan
Copy link
Contributor

johnpryan commented Jun 1, 2022

I don't know the details of these packages, but I'm unclear as to why the solution isn't just to have a normal, pub-based dependency on go_router from the other package's example.

If we did that, wouldn't we run into a similar problem? When a change to go_router that breaks go_router_builder is merged and published it wouldn't be detected until the next CI run.

@stuartmorgan-g
Copy link
Collaborator

Unless the dependency were an any dependency—which it should not be—then the only way that could happen is if someone makes a breaking change to go_router without changing its major version number. Which, yes, would break CI post-publish, but it would also break all clients of go_router in the wild.

@johnpryan
Copy link
Contributor

johnpryan commented Jun 1, 2022

In this case, there wasn't enough test coverage to catch the bug fixed in #2177, but we could certainly make go_router_builder depend on go_router: ^4.0.0 from Pub.


environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't the package depend on flutter 3.0.0 ? i am getting WidgetsBinding.instance warnings
because of static WidgetsBinding get _binding => WidgetsBinding.instance!;

johnpryan added a commit that referenced this pull request Jun 7, 2022
johnpryan added a commit that referenced this pull request Jun 14, 2022
johnpryan added a commit that referenced this pull request Jun 15, 2022
* Revert "Revert "[go_router] Refactor RouterDelegate into functional pieces (#1653)" (#2183)"

This reverts commit d39ffb1.

* [go_router] Continue searching for top-level routes if the recursive search doesn't find any

* Remove Route.push from demo app

* update CHANGELOG.md

* Avoid pushing the same page in example

bump go_router_builder to 1.0.5

* Change published version to 4.0.0

* Specify dart SDK version >=2.17.0 to avoid analyzer errors

Analyzing go_router...

  error - lib/src/go_route_information_provider.dart:24:41 - A value of type 'WidgetsBinding?' can't be returned from the function '_binding' because it has a return type of 'WidgetsBinding'. - return_of_invalid_type
  error - lib/src/go_router.dart:51:33 - The property 'platformDispatcher' can't be unconditionally accessed because the receiver can be 'null'. Try making the access conditional (using '?.') or adding a null check to the target ('!'). - unchecked_use_of_nullable_value

2 issues found.

* Specify flutter >=3.0.0 in go_router

* Apply suggestions from code review

Co-authored-by: Loïc Sharma <[email protected]>

* Apply suggestions from code review

* Update packages/go_router/lib/src/go_route_information_parser.dart

Co-authored-by: Loïc Sharma <[email protected]>

* Update packages/go_router/lib/src/go_route_information_parser.dart

Co-authored-by: Loïc Sharma <[email protected]>

* Update packages/go_router/lib/src/go_route_information_parser.dart

Co-authored-by: Loïc Sharma <[email protected]>

* Update packages/go_router/lib/src/go_route_information_parser.dart

Co-authored-by: Loïc Sharma <[email protected]>

* Add '/' route to test

* add go_route_information_provider_test.dart

* Add test for redirect detection in GoRouteInformationParser

* format

Co-authored-by: Loïc Sharma <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants