Skip to content
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

[go_router] Cleans up route match API and introduces dart fix #3819

Merged
merged 3 commits into from
Apr 29, 2023

Conversation

chunhtai
Copy link
Contributor

Clean up API around RouteMatch/RouteMatchList/GoRouterState,

This is a breaking change that renamed some of the GoRouterState property to have a more descriptive name as flutter style guide suggested https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#avoid-abbreviations

also introducing dart fix to help with migration

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.

@@ -0,0 +1 @@
# This ensures that parent analysis options do not accidentally break the fix tests.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is causing issues with CI: "Unexpected local analysis options"

@chunhtai
Copy link
Contributor Author

@stuartmorgan can you take a look at the ci setup?

@@ -19,6 +19,9 @@ analyzer:
# Ignore generated files
- '**/*.g.dart'
- '**/*.mocks.dart' # Mockito @GenerateMocks
# Ignore go_router dart fix test file.
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 am not sure if this is the right place to disable the lint

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could make a custom analysis_options.yaml in packages/go_router/ that includes this one, and then adds this exclude. Then you'd need to add go_router to script/configs/custom_analysis.yaml.

That would make it more obvious locally that something strange is going on with analysis.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, this doesn't work. In order to let dart fix --compare-to-golden to work. I can't ignore the lint using analysis_options.yaml as the dart fix would only touch the code that has analyzer error or warning. That means I can't do any kind or ignore that would affect dart analyze.

I took a look at the flutter repro, it looks like they wrote the custom analyzer script to ignore these lint.

I think I will have to need to update the code in flutter_plugin_tools to ignore the folder when running analyze.

Do you have any other idea that I should do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nvm, it seems like i can use some analyzer-options trick to get around this

@@ -19,6 +19,9 @@ analyzer:
# Ignore generated files
- '**/*.g.dart'
- '**/*.mocks.dart' # Mockito @GenerateMocks
# Ignore go_router dart fix test file.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could make a custom analysis_options.yaml in packages/go_router/ that includes this one, and then adds this exclude. Then you'd need to add go_router to script/configs/custom_analysis.yaml.

That would make it more obvious locally that something strange is going on with analysis.

.cirrus.yml Outdated
- name: go_router_dart_fix_test
test_script:
- cd packages/go_router/test_fix
- dart fix --compare-to-golden
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want custom, package-specific tests, they should be in your package, not in the CI config. The mechanism that's in place for that is the custom-test repo tooling command, which looks for a tool/run_tests.dart in your package, and runs it if it's there. packages/cross_file/tool/run_tests.dart is a simple example you can follow. (There's a legacy mode that uses a run_script.sh, but please do not add a new shell-based script. Those are only there because they predate standardizing on repo tooling.)

By default it will run on every host platform, so if you only run it on Linux you should check for Platform.isLinux in your script, and no-op if it's not Linux.

@chunhtai chunhtai force-pushed the clean-up-routematch branch 2 times, most recently from 0a196ef to 663d38a Compare April 26, 2023 21:49
@chunhtai
Copy link
Contributor Author

Hi @johnpryan , I updated some code, can you take another look

Hi @stuartmorgan , can you take a look at the ci setup again, I addressed all comments

@@ -37,6 +37,7 @@ See the API documentation for details on the following topics:
- [Error handling](https://pub.dev/documentation/go_router/latest/topics/Error%20handling-topic.html)

## Migration guides
- [Migrating to 7.0.0](https://docs.google.com/document/d/10Xbpifbs4E-zh6YE5akIO8raJq_m3FIXs6nUGdOspOg).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

would update to flutter go link once website is unfrozen

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

The CI parts LGTM with small comments.

@@ -5,5 +5,6 @@
# mac/windows CI test runs.

- cross_file
- go_router
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: I would prefer the platform check to be in the script (e.g., exit immediately if (!Platform.isLinux)), with an explanation there as to why it's platform-limited, to make the logic as localized as possible. This exclude system was needed because we still have some .sh scripts, but I hope to eventually eliminate the custom test exclude files.

// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Runs `dart test -p chrome` in the root of the cross_file package.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not accurate.

@@ -1,3 +1,19 @@
## 7.0.0

- **BREAKING CHANGE**
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: **BREAKING CHANGES**:

- For the below changes, please follow the [migration guide](https://docs.google.com/document/d/10Xbpifbs4E-zh6YE5akIO8raJq_m3FIXs6nUGdOspOg).
- `params` and `queryParams` in `BuildContext`'s `namedLocation`, `pushNamed`, `pushReplacementNamed`
`replaceNamed` have been renamed to `pathParameters` and `queryParameters`.
- Cleans up API and makes RouteMatchList immutable
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: missing .

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 28, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 28, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Apr 28, 2023

auto label is removed for flutter/packages, pr: 3819, due to - The status or check suite repo_checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 28, 2023
@auto-submit auto-submit bot merged commit b017367 into flutter:main Apr 29, 2023
sybrands-place pushed a commit to sybrands-place/packages that referenced this pull request May 1, 2023
* main: (46 commits)
  [go_router] Cleans up route match API and introduces dart fix (flutter#3819)
  [camerax] Add `LifecycleOwner` Proxy (flutter#3837)
  [file_selector] Add getDirectoryPaths implementation for Windows (flutter#3704)
  [various] Update Android example min SDKs (flutter#3847)
  Bump github/codeql-action from 2.2.12 to 2.3.2 (flutter#3838)
  [camerax] Implement Image Streaming (flutter#3454)
  [various] update agp and gradle for all examples in packages (flutter#3822)
  Update xcode to 14c18 (flutter#3774)
  [camera_android] Add NV21 as an image stream format flutter#3277 (flutter#3639)
  [go_router] Remove unused navigator keys (flutter#3708)
  [image_picker] Move I/O operations to a separate thread (flutter#3506)
  [pigeon]: Bump org.jetbrains.kotlin:kotlin-gradle-plugin from 1.8.20 to 1.8.21 in /packages/pigeon/platform_tests/test_plugin/android (flutter#3824)
  [pigeon] Reland: Add an initial example app (flutter#3832)
  Roll Flutter from c9004ff to 66fa4c5 (68 revisions) (flutter#3830)
  [various] Conditionalize the namespace in all Android plugins (flutter#3836)
  [in_app_pur]: Bump com.android.billingclient:billing from 5.1.0 to 5.2.0 in /packages/in_app_purchase/in_app_purchase_android/android (flutter#3672)
  [auick_action_ios] Retries multiple times to not fail ci when there is a flake (flutter#3823)
  Swap some iOS package CODEOWNERS (flutter#3793)
  [various] Add `targetCompatibility` to build.gradle (flutter#3825)
  [various] Set cmake_policy versions (flutter#3828)
  ...
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 1, 2023
Roll Packages from 7e3f5da to de6131d (41 revisions)

flutter/packages@7e3f5da...de6131d

2023-05-01 reidbaker@google.com I122213 update non examples (flutter/packages#3846)
2023-04-29 47866232+chunhtai@users.noreply.github.com [go_router] Cleans up route match API and introduces dart fix (flutter/packages#3819)
2023-04-29 43054281+camsim99@users.noreply.github.com [camerax] Add `LifecycleOwner` Proxy (flutter/packages#3837)
2023-04-29 stuartmorgan@google.com [file_selector] Add getDirectoryPaths implementation for Windows (flutter/packages#3704)
2023-04-29 stuartmorgan@google.com [various] Update Android example min SDKs (flutter/packages#3847)
2023-04-28 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 2.2.12 to 2.3.2 (flutter/packages#3838)
2023-04-28 43054281+camsim99@users.noreply.github.com [camerax] Implement Image Streaming (flutter/packages#3454)
2023-04-28 reidbaker@google.com [various] update agp and gradle for all examples in packages (flutter/packages#3822)
2023-04-28 54558023+keyonghan@users.noreply.github.com Update xcode to 14c18 (flutter/packages#3774)
2023-04-28 andrewjohncoutts@gmail.com [camera_android] Add NV21 as an image stream format #3277 (flutter/packages#3639)
2023-04-28 gautier.bayzelon@gmail.com [go_router] Remove unused navigator keys (flutter/packages#3708)
2023-04-28 JeroenWeener@users.noreply.github.com [image_picker] Move I/O operations to a separate thread (flutter/packages#3506)
2023-04-28 49699333+dependabot[bot]@users.noreply.github.com [pigeon]: Bump org.jetbrains.kotlin:kotlin-gradle-plugin from 1.8.20 to 1.8.21 in /packages/pigeon/platform_tests/test_plugin/android (flutter/packages#3824)
2023-04-28 stuartmorgan@google.com [pigeon] Reland: Add an initial example app (flutter/packages#3832)
2023-04-28 engine-flutter-autoroll@skia.org Roll Flutter from c9004ff to 66fa4c5 (68 revisions) (flutter/packages#3830)
2023-04-28 stuartmorgan@google.com [various] Conditionalize the namespace in all Android plugins (flutter/packages#3836)
2023-04-27 49699333+dependabot[bot]@users.noreply.github.com [in_app_pur]: Bump com.android.billingclient:billing from 5.1.0 to 5.2.0 in /packages/in_app_purchase/in_app_purchase_android/android (flutter/packages#3672)
2023-04-27 ychris@google.com [auick_action_ios] Retries multiple times to not fail ci when there is a flake (flutter/packages#3823)
2023-04-26 magder@google.com Swap some iOS package CODEOWNERS (flutter/packages#3793)
2023-04-26 stuartmorgan@google.com [various] Add `targetCompatibility` to build.gradle (flutter/packages#3825)
2023-04-26 stuartmorgan@google.com [various] Set cmake_policy versions (flutter/packages#3828)
2023-04-26 stuartmorgan@google.com [path_provider] Allow `win32` up to version 4.x (flutter/packages#3820)
2023-04-26 stuartmorgan@google.com [tool] Move Android lint checks (flutter/packages#3816)
2023-04-25 evace93@gmail.com [google_maps_flutter_android] Fix Android lint warnings (flutter/packages#3751)
2023-04-25 49699333+dependabot[bot]@users.noreply.github.com [in_app_pur]: Bump androidx.annotation:annotation from 1.5.0 to 1.6.0 in /packages/in_app_purchase/in_app_purchase_android/android (flutter/packages#3381)
2023-04-25 jason-simmons@users.noreply.github.com Update test golden images for the latest Skia roll (flutter/packages#3787)
2023-04-25 stuartmorgan@google.com [various] Adds Android namespace (flutter/packages#3791)
2023-04-25 reidbaker@google.com [shared_preferences] Update gradle/agp in example apps (flutter/packages#3809)
2023-04-24 43640732+dancamdev@users.noreply.github.com [go_router] Adds name to TypedGoRoute (flutter/packages#3702)
2023-04-22 10687576+bparrishMines@users.noreply.github.com [webview_flutter] Adds support to receive permission requests (flutter/packages#3543)
2023-04-21 stuartmorgan@google.com [google_sign_in] Fix Android Java warnings (flutter/packages#3762)
2023-04-21 stuartmorgan@google.com [local_auth] Fix enum return on Android (flutter/packages#3780)
2023-04-21 stuartmorgan@google.com [pigeon] Warn when trying to use enums in collections (flutter/packages#3782)
2023-04-21 10687576+bparrishMines@users.noreply.github.com [webview_flutter_android] [webview_flutter_wkwebview] Platform implementations for supporting permission requests (flutter/packages#3792)
2023-04-21 scheglov@google.com [pigeon] Update for compatibility with a future change to the analyzer. (flutter/packages#3789)
2023-04-21 10687576+bparrishMines@users.noreply.github.com [camera_android] Fix Android lint warnings  (flutter/packages#3716)
2023-04-21 10687576+bparrishMines@users.noreply.github.com [webview_flutter_platform_interface] Adds method to receive permission requests (flutter/packages#3767)
2023-04-21 magder@google.com [image_picker_ios] In unit test write and read kCGImagePropertyExifUserComment property (flutter/packages#3783)
2023-04-21 widrans@gmail.com [go_router_builder] Fixed the return value of the generated push method (flutter/packages#3650)
2023-04-21 JeroenWeener@users.noreply.github.com [image_picker] Mention `launchMode: singleInstance` in README (flutter/packages#3759)
2023-04-21 stuartmorgan@google.com Revert "[pigeon] Add an initial example app" (flutter/packages#3785)

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
...
@ahmednfwela
Copy link
Contributor

@chunhtai I just tried v7.0.0 and dart fix isn't getting computed at all
image

>  dart fix --apply   
Computing fixes in example...
Nothing to fix!

@chunhtai
Copy link
Contributor Author

chunhtai commented May 1, 2023

@ahmednfwela thanks for reporting. It is weird that It does work if I point the go_router to local directory in pubspec.yaml. I filed a bug dart-lang/sdk#52233

For now, i think you can workaround it by doing a local check out of the go_router and override your dependencies in pubspec.yaml with the path, and run flutter pub get and dart fix --apply again

@ahmednfwela
Copy link
Contributor

@chunhtai nope, doesn't even work when importing path
image

@chunhtai
Copy link
Contributor Author

chunhtai commented May 1, 2023

@ahmednfwela

Can you try git clone the entire package https://github.com/flutter/packages and then link the dependency into the go_router inside the local copy of the repo?

you will need to do flutter pub get to make sure the go_router reference is properly updated

@ahmednfwela
Copy link
Contributor

ahmednfwela commented May 1, 2023

  1. I cloned the entire package repo to E:\Projects\Packages\flutter_packages
  2. went to packages/go_router/example/lib/named_routes.dart in the cloned repo
  3. renamed state.pathParameters to state.params
  4. Lint appears in vscode
    image

  1. In my project
  2. add dependency override:
dependency_overrides: 
  go_router:
    path: E:\Projects\Packages\flutter_packages\packages\go_router
  1. flutter pub upgrade
    correct path appears:
Warning: You are using these overridden dependencies:
! go_router 7.0.0 from path E:\Projects\Packages\flutter_packages\packages\go_router
  1. go to a similar state.queryParams entry
  2. lints don't appear
    image

@chunhtai
Copy link
Contributor Author

chunhtai commented May 1, 2023

@ahmednfwela I didn't use dependency_override, can you try using the path in
dependencies: in pubspec yaml directly?

@ahmednfwela
Copy link
Contributor

@chunhtai doesn't make a difference

@chunhtai
Copy link
Contributor Author

chunhtai commented May 1, 2023

I am sorry to hear that. since this is likely a dart sdk issue, there isn't much I can do to fix this. I will update the migration doc with more detail steps.

@ahmednfwela
Copy link
Contributor

ahmednfwela commented May 1, 2023

btw here is my environment, so maybe it's a windows only problem ?

flutter doctor -v
[√] Flutter (Channel stable, 3.7.12, on Microsoft Windows [Version 10.0.19045.2846], locale en-US)
    • Flutter version 3.7.12 on channel stable at C:\tools\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4d9e56e694 (2 weeks ago), 2023-04-17 21:47:46 -0400
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc1)
    • Android SDK at C:\Users\ahmed\AppData\Local\Android\Sdk
    • Platform android-33, build-tools 31.0.0-rc1
    • ANDROID_HOME = C:\Users\ahmed\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33530.505
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2021.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] VS Code, 64-bit edition (version 1.77.3)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.15.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.2846]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 112.0.5615.138
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 112.0.1722.64

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

auto-submit bot pushed a commit that referenced this pull request May 2, 2023
#3819

Fixed go_router_builder to generate code for go_router v7.0.0.
joshpetit pushed a commit to joshpetit/packages that referenced this pull request May 2, 2023
flutter#3819

Fixed go_router_builder to generate code for go_router v7.0.0.
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
…r#3819)

Clean up API around RouteMatch/RouteMatchList/GoRouterState,

This is a breaking change that renamed some of the GoRouterState property to have a more descriptive name as flutter style guide suggested https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#avoid-abbreviations

also introducing dart fix to help with migration
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
flutter#3819

Fixed go_router_builder to generate code for go_router v7.0.0.
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.

4 participants