You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6238260
Browse filesBrowse the repository at this point in the historyBrowse files
[flutter_tools] Fix StateError in testCompilerBuildNativeAssets when package root does not match projectUri (flutter#192942)
Fixes a `StateError (Bad state: No element)` crash in
`testCompilerBuildNativeAssets` when running `flutter test` in a
directory whose URI does not strictly match any package root in
`package_config.json` (such as when working through symlinked project
directories, monorepos/workspaces, or ancestor `package_config.json`
files).
Replaces the strict `firstWhere((Package p) => p.root == projectUri)`
lookup with `findRunPackageName`, which resolves the target package name
using the following fallback order:
1. Direct URI match against `projectUri`.
2. Canonicalized filesystem path match (resolving symlinks and trailing
slashes).
3. Matching the project's `pubspec.yaml` `appName` in `packageConfig`.
4. Returning `null` if no package can be resolved, logging a warning and
skipping native assets hooks gracefully instead of crashing.
Fixesflutter#192933
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
0 commit comments