Sitelet https://github.com/flutter/flutter/pull/191624
Skip to content

[beta] Only exclude platform directories that actually exist in analysis_options.yaml - #191624

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.48-candidate.0from
flutteractionsbot:cp-beta-c7a822e59b5b37c4fa74f0cc71e9d1f4e25ac7ff
Aug 25, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.48-candidate.0from
flutteractionsbot:cp-beta-c7a822e59b5b37c4fa74f0cc71e9d1f4e25ac7ff

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

Issue Link:

#191131

Impact Description:

AnalysisOptionsMigration writes a fixed seven-entry exclude list (android/**, ios/**, web/**, windows/**, macos/**, linux/**, build/**) into analysis_options.yaml on every flutter pub get / analyze / run / build, regardless of which directories the project actually contains. A Dart-only package (e.g. dart create -t web) that uses web/ as a source directory gets it silently excluded from analysis the first time any Flutter command touches the package, and there is no opt-out — the entries are restored on every command.

Changelog Description:

[flutter/191131] Only exclude platform directories that actually exist, so web/** sources in Dart web packages are no longer silently dropped from analysis.

Workaround:

None — every Flutter command that reaches ensureReadyForPlatformSpecificTooling restores the full exclude list; the only way to keep the entries out is to not run Flutter tooling in the package.

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

  1. dart create -t web repro && cd repro && flutter pub get — confirm web/** is not added to the exclude list and dart analyze still reports errors in web/main.dart.
  2. flutter create --platforms=android,ios app — confirm analysis_options.yaml only excludes build/**, android/**, and ios/**.
  3. Run packages/flutter_tools/test/general.shard/migrations/analysis_options_migration_test.dart and packages/flutter_tools/test/commands.shard/permeable/create_test.dart.

…ions.yaml (flutter#191151)

`AnalysisOptionsMigration` wrote a fixed seven-entry `exclude` list
(`android/**`, `ios/**`, `web/**`, `windows/**`, `macos/**`, `linux/**`,
plus `build/**`) into `analysis_options.yaml` on every `flutter pub get`
/ `flutter analyze` / `flutter run` / `flutter build`, regardless of
what the project actually contains.

Two concrete problems from this:
- A Dart-only package (e.g. `dart create -t web`) that uses `web/` as a
real source directory gets it silently excluded from analysis the first
time any `flutter` command touches the package (this happens in mixed
Flutter/Dart monorepos and Dart workspaces).
- A Flutter app created with `flutter create --platforms=android,ios`
still gets exclusions for `web/`, `windows/`, `macos/`, and `linux/`,
which it doesn't have, and `ProjectMigrator` has no opt-out — every
command restores the full list.

Fix:
- `AnalysisOptionsMigration.migrate()` now skips entirely when the
package has no `flutter` dependency (i.e. it isn't a Flutter project at
all — the discriminator suggested in the issue).
- The exclude list is now built conditionally from
`project.<platform>.existsSync()` for each platform, so only directories
the project actually has as platform scaffolds are excluded. `build/**`
stays unconditional.
- `templates/app/analysis_options.yaml.tmpl` (used by `flutter create`)
gets the same per-platform conditionals via the existing mustache
context (`{{#android}}`, `{{#ios}}`, etc.), so newly created projects
don't get the fixed list either.

Fixes flutter#191131

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [ ] 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].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Aug 25, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor Author

@AlexV525 please fill out the PR description above, afterwards the release team will review this request.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 25, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 25, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@AlexV525 AlexV525 changed the title [CP-beta]Only exclude platform directories that actually exist in analysis_options.yaml [beta] Only exclude platform directories that actually exist in analysis_options.yaml Aug 25, 2026

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

Copy link
Copy Markdown
Contributor

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 modifies the analysis options migration and template generation to exclude platform directories only if they exist in the project, and skips the migration entirely for pure Dart packages. Relevant tests have been added and updated to verify these changes. No review comments were provided, and there is no additional feedback.

@camsim99 camsim99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was wondering if you would CP this to beta too :) LGTM

@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 25, 2026
@auto-submit
auto-submit Bot merged commit cbc691c into flutter:flutter-3.48-candidate.0 Aug 25, 2026
10 checks passed
@flutteractionsbot
flutteractionsbot deleted the cp-beta-c7a822e59b5b37c4fa74f0cc71e9d1f4e25ac7ff branch August 25, 2026 17:41
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 CICD Run CI/CD cp: review Cherry-picks in the review queue tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants