-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix AssertionError by adding routeInformationProvider to MaterialApp.router(go_router_builder/example
)
#4300
Conversation
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. |
@@ -18,6 +18,7 @@ class App extends StatelessWidget { | |||
|
|||
@override | |||
Widget build(BuildContext context) => MaterialApp.router( | |||
routeInformationProvider: _router.routeInformationProvider, |
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.
you can use MaterialApp.router(routerConfig: _router)
directly. It looks like we don't have a test for this example, can you add a simple test like other example just to make sure things can compile?
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.
Can you also update other example to use routerConfig 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.
Sure, I can add a test for this example to ensure it compiles correctly. I will also update the other examples to use routerConfig. 😀
Thank you for your feedback, @chunhtai. I have updated Additionally, I've added a test for Please review the changes and let me know if anything else is required. |
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.
it looks like all_types.dart is not using routerConfig, can you also update that one? beside format, everything else looks good. Thanks for fixing this!
@@ -98,8 +96,7 @@ class LoginRoute extends GoRouteData { | |||
final String? fromPage; | |||
|
|||
@override | |||
Widget build(BuildContext context, GoRouterState state) => | |||
LoginScreen(from: fromPage); | |||
Widget build(BuildContext context, GoRouterState state) => LoginScreen(from: fromPage); |
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.
we use dart format .
on this project directly, this may be causing repro-check failures. Can you run dart format
to reformat these files?
This PR is an extension of the previous PR #4300 that I submitted. The previous PR, being based on the main branch, was closed and the contents were copied to a new branch in order to make further contributions.� In the previous PR, an assertion error was fixed by adding `routeInformationProvider` to `MaterialApp.router`. After a series of code reviews, we updated to use routerConfig and added some test codes. All the contents have been transferred to the current `bugfix/RouterConfig` branch. --- *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
This PR fixes an AssertionError that occurs when building the MaterialApp widget. The error message is as follows:
This error was due to the omission of
routeInformationProvider
in the MaterialApp.router setup. The original code was:To fix this error, I added routeInformationProvider: _router.routeInformationProvider, to MaterialApp.router:
With this fix, the AssertionError no longer occurs and the MaterialApp builds without issues.
Additionally, I considered changing the
MaterialApp.router
construction from:to
However, as the
lib/main.dart
file is already set up with the first MaterialApp.router construction, I decided to maintain its original form.Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.
List which issues are fixed by this PR. You must list at least one issue.
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.