Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[go_router_builder] Fixes incorrect separator at location path on Windows.#1690

Merged
fluttergithubbot merged 4 commits intoflutter:mainfrom
moko256:moko256_go_router_builder_fix_separator
May 6, 2022
Merged

[go_router_builder] Fixes incorrect separator at location path on Windows.#1690
fluttergithubbot merged 4 commits intoflutter:mainfrom
moko256:moko256_go_router_builder_fix_separator

Conversation

@moko256
Copy link
Contributor

@moko256 moko256 commented Apr 30, 2022

The go_router_builder is using path.joinAll to concat route and create location, but it uses backslash as path separators on Windows.
This PR will replace that with path.url.joinAll, which uses slash. The builder will be able to generate slash-separated location on Windows, same on the other platforms.

I didn't know how to write test in this case. The build runner will generate correct main.g.dart in example project on Windows.

This PR will fix flutter/flutter#102710.

No changes in flutter/tests

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.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@moko256 moko256 changed the title [go_router_builder] On Windows, use path.url.joinAll instead of path.joinAll to avoid backslash separator in route path. [go_router_builder] Fixes incorrect separator at location path on Windows. Apr 30, 2022
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

it looks like the change log is out of date, can you rebase off the main branch and fix the conflict?

The change makes sense, but we need a test in order to merge this pr. Can you write a example that cover this use case in example/ folder?

@moko256 moko256 force-pushed the moko256_go_router_builder_fix_separator branch from 1b1e5cf to 467db94 Compare May 6, 2022 00:06
@moko256
Copy link
Contributor Author

moko256 commented May 6, 2022

I rebased it and pushed it.

The main.dart in example already covers this. These line is included as a reproducible example in flutter/flutter#102710.

@TypedGoRoute<HomeRoute>(
path: '/',
routes: <TypedGoRoute<GoRouteData>>[
TypedGoRoute<FamilyRoute>(
path: 'family/:fid',
routes: <TypedGoRoute<GoRouteData>>[
TypedGoRoute<PersonRoute>(
path: 'person/:pid',
routes: <TypedGoRoute<GoRouteData>>[
TypedGoRoute<PersonDetailsRoute>(path: 'details/:details'),
],
),
],
)
],
)

@chunhtai
Copy link
Contributor

chunhtai commented May 6, 2022

I rebased it and pushed it.

The main.dart in example already covers this. These line is included as a reproducible example in flutter/flutter#102710.

@TypedGoRoute<HomeRoute>(
path: '/',
routes: <TypedGoRoute<GoRouteData>>[
TypedGoRoute<FamilyRoute>(
path: 'family/:fid',
routes: <TypedGoRoute<GoRouteData>>[
TypedGoRoute<PersonRoute>(
path: 'person/:pid',
routes: <TypedGoRoute<GoRouteData>>[
TypedGoRoute<PersonDetailsRoute>(path: 'details/:details'),
],
),
],
)
],
)

but the file main.g.dart does not change after this change. is it needed to be run in windows host?

@moko256
Copy link
Contributor Author

moko256 commented May 6, 2022

I rebased it and pushed it.
The main.dart in example already covers this. These line is included as a reproducible example in flutter/flutter#102710.

@TypedGoRoute<HomeRoute>(
path: '/',
routes: <TypedGoRoute<GoRouteData>>[
TypedGoRoute<FamilyRoute>(
path: 'family/:fid',
routes: <TypedGoRoute<GoRouteData>>[
TypedGoRoute<PersonRoute>(
path: 'person/:pid',
routes: <TypedGoRoute<GoRouteData>>[
TypedGoRoute<PersonDetailsRoute>(path: 'details/:details'),
],
),
],
)
],
)

but the file main.g.dart does not change after this change. is it needed to be run in windows host?

Yes, and to see generated result you have to re-generate main.g.dart with flutter pub run build_runner build on Windows.
The generated main.g.dart with a version before this PR on Windows differs from committed one before this PR.

@chunhtai
Copy link
Contributor

chunhtai commented May 6, 2022

sounds good, I am working on another pr to run test on windows platform, so test wise, this pr should be good

based on the CI

�[31mThe following packages had errors:�[0m
�[31m go_router_builder:
Missing version change�[0m
�[31mSee above for full details.�[0m

you need to bump the package version.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

@chunhtai chunhtai requested a review from kevmoo May 6, 2022 17:09
Copy link
Contributor

@kevmoo kevmoo left a comment

Choose a reason for hiding this comment

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

Great find! Thanks!

@fluttergithubbot fluttergithubbot merged commit 5a3f015 into flutter:main May 6, 2022
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.

[go_router_builder] generated location is not correct in some cases

4 participants