Skip to content

Conversation

chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Jun 2, 2023

Several thing.

  1. I move all the imperative logic from RouterDelegate to RouteInformationParser, so that the imperative API can go through Router parsing pipeline. The Parser will handle modifying mutating RouteMatchList and produce the final RouteMatchList. The RouterDelegate would only focus on building the widget base on the final RouteMatchList
  2. combine RouteMatcher and Redirector with RouteConfiguration. I feel that instead of passing three class instances around, we should probably just have one class for all the route parsing related utility.
  3. serialize routeMatchList and store into browser history. This way we can let backward and forward button to reflect imperative operation as well.
  4. Some minor clean ups

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.

@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing really change for this class, most of the code is copy paste from redirect.dart and matching.dart

@@ -149,3 +146,281 @@ class ImperativeRouteMatch<T> extends RouteMatch {
@override
int get hashCode => identityHashCode(this);
}

/// The list of [RouteMatch] objects.
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 a copy paste from matching.dart

@chunhtai chunhtai force-pushed the refactor-imperative branch from abb9022 to 9305fe5 Compare June 5, 2023 17:12
@chunhtai chunhtai requested a review from johnpryan June 5, 2023 20:04
@chunhtai
Copy link
Contributor Author

chunhtai commented Jun 5, 2023

ci seems to be weird this time, will try pushing a new commit later

}) {
switch (type) {
case NavigatingType.push:
return base!.push(

Choose a reason for hiding this comment

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

Is it safe to bang base and completer without doing a null check beforehand?

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 they are null, it means something wrong with the GoRouteInformationProvider that provides malformed RouteInformation

@chunhtai chunhtai changed the title [go_router] Refactors imperative APIs and brwoser history [go_router] Refactors imperative APIs and browser history Jun 6, 2023
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, a few nitpicks.

}

/// Handles encoding and decoding of [RouteMatchList] objects to a format
/// suitable for using with [StandardMessageCodec].
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any benefit / reason this doesn't extend the Codec class from dart:convert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

return;
}
replace = _valueInEngine == _kEmptyRouteInformation;
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

break; isn't needed if you're using Dart 3

@chunhtai chunhtai force-pushed the refactor-imperative branch from 44430a3 to afb4f7a Compare June 7, 2023 19:24
@chunhtai chunhtai requested a review from johnpryan June 7, 2023 19:27
@chunhtai
Copy link
Contributor Author

chunhtai commented Jun 7, 2023

Hi @johnpryan, I updated this pr, the change is in the last commit

  1. Makes RouteMatchListCodec to implement Codec
  2. Move error and extra property from each RouteMatch to RouteMatchList, since they will be the same for every RouteMatch anyway.

@chunhtai chunhtai force-pushed the refactor-imperative branch from afb4f7a to e4b4463 Compare June 7, 2023 20:51
@chunhtai chunhtai force-pushed the refactor-imperative branch from e4b4463 to ed16a13 Compare June 7, 2023 21:46
@chunhtai
Copy link
Contributor Author

chunhtai commented Jun 7, 2023

waiting for migration guide to merge flutter/website#8853

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 7, 2023
@auto-submit auto-submit bot merged commit 010ba50 into flutter:main Jun 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 8, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jun 8, 2023
flutter/packages@a84b2c2...e13b8c4

2023-06-08 stuartmorgan@google.com [tool] Only run unit tests in Chrome for inline web (flutter/packages#4153)
2023-06-08 jason-simmons@users.noreply.github.com [in_app_purchase] Make the _FeatureCard constructor const in the Android example app (flutter/packages#4162)
2023-06-08 stuartmorgan@google.com [shared_preferences] Fix initialization race (flutter/packages#4159)
2023-06-07 47866232+chunhtai@users.noreply.github.com [go_router] Refactors imperative APIs and browser history (flutter/packages#4134)
2023-06-07 stuartmorgan@google.com [various] Add `http` 1.0 compatibility (flutter/packages#4147)
2023-06-07 32538273+ValentinVignal@users.noreply.github.com [go_router_builder] Accept required parameters not in path (flutter/packages#4039)
2023-06-07 engine-flutter-autoroll@skia.org Roll Flutter from 0b74153 to 8a5c22e (46 revisions) (flutter/packages#4160)
2023-06-07 scheglov@google.com [pigeon] Require analyzer 5.13.0, prepare for NamedType refactoring. (flutter/packages#4127)
2023-06-07 engine-flutter-autoroll@skia.org Roll Flutter (stable) from f92f441 to 682aa38 (1 revision) (flutter/packages#4157)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: go_router
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants