Skip to content

Read flutterRoot from package_config.json instead of parsing up the flutter package path#5880

Merged
DanTup merged 2 commits intomasterfrom
read-flutter-root
Jan 20, 2026
Merged

Read flutterRoot from package_config.json instead of parsing up the flutter package path#5880
DanTup merged 2 commits intomasterfrom
read-flutter-root

Conversation

@DanTup
Copy link
Member

@DanTup DanTup commented Jan 20, 2026

Fixes #5728

@DanTup DanTup added this to the v3.128.0 milestone Jan 20, 2026
@DanTup DanTup added is enhancement An enhancement or improvement that should be listed in release notes but is not a bug fix. in flutter Relates to running Flutter apps labels Jan 20, 2026
@DanTup DanTup requested a review from Copilot January 20, 2026 11:30
@DanTup
Copy link
Member Author

DanTup commented Jan 20, 2026

@codex review
/gemini review

@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.29%. Comparing base (1a85e1e) to head (8f4fc9e).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5880      +/-   ##
==========================================
- Coverage   67.32%   67.29%   -0.04%     
==========================================
  Files         168      168              
  Lines       12894    12899       +5     
  Branches     2554     2556       +2     
==========================================
- Hits         8681     8680       -1     
- Misses       3762     3766       +4     
- Partials      451      453       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enhances the Flutter SDK path detection by reading the flutterRoot field directly from package_config.json instead of parsing it from the flutter package path. This provides a more reliable way to determine the Flutter SDK location.

Changes:

  • Added flutterRootPath getter to PackageMap class hierarchy to read the flutterRoot field from package config
  • Updated extractFlutterSdkPathFromPackagesFile to prioritize flutterRoot field with fallback to package path parsing
  • Added comprehensive tests validating both the new direct path reading and the fallback behavior

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/shared/pub/package_map.ts Added flutterRootPath getter to base PackageMap class and PackageConfigJsonPackageMap, and extended PackageJsonConfig interface to include optional flutterRoot field
src/shared/utils/fs.ts Modified extractFlutterSdkPathFromPackagesFile to prioritize flutterRootPath over package path with nullish coalescing operator
src/test/dart/utils/fs.test.ts Added comprehensive test suite for extractFlutterSdkPathFromPackagesFile covering both package path fallback and flutterRoot prioritization scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a good improvement, updating the logic to read the Flutter SDK root from package_config.json instead of relying on parsing the flutter package path. This should be more reliable. I've found one potential bug in the implementation where the new flutterRootPath could be incorrectly modified. I've provided a comment with details on the issue. I've also suggested an additional test case to cover this edge case and prevent future regressions. With that fix, this change will be solid.

@DanTup DanTup merged commit ee99a45 into master Jan 20, 2026
21 checks passed
@DanTup DanTup deleted the read-flutter-root branch January 20, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in flutter Relates to running Flutter apps is enhancement An enhancement or improvement that should be listed in release notes but is not a bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use flutterRoot instead of looking for the flutter package when reading the sdk path from .package_config.json

2 participants