Skip to content

Conversation

@bkonyi
Copy link
Contributor

@bkonyi bkonyi commented Nov 12, 2025

The flutter tool creates various directories for ephemeral state while executing commands. In some situations, these directories contain or link to other Dart / Flutter projects with '.dart' sources or 'pubspec.yaml's. If these files change while the widget previewer is active (e.g., due to a flutter pub get downloading and configuring new plugins for the project), the previewer's directory watcher will detect the change and attempt to analyze the source. This causes an exception to be thrown by the analyzer as the modified file path does not have a valid analysis context.

This change adds additional checks to the PreviewDetector that allow for ignoring changes to pubspec.yamls and .dart sources under known ephemeral directories (e.g., build/,
linux/flutter/ephemeral/, etc), as well as .dart files that aren't associated with an analysis context.

Fixes #178317

…ries

The `flutter` tool creates various directories for ephemeral state while
executing commands. In some situations, these directories contain or
link to other Dart / Flutter projects with '.dart' sources or
'pubspec.yaml's. If these files change while the widget previewer is
active (e.g., due to a `flutter pub get` downloading and configuring new
plugins for the project), the previewer's directory watcher will detect
the change and attempt to analyze the source. This causes an exception
to be thrown by the analyzer as the modified file path does not have a
valid analysis context.

This change adds additional checks to the `PreviewDetector` that allow
for ignoring changes to `pubspec.yaml`s and `.dart` sources under known
ephemeral directories (e.g., build/,
linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't
associated with an analysis context.

Fixes #178317
@bkonyi bkonyi requested a review from jyameo November 12, 2025 18:56
@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Nov 12, 2025
Copy link
Contributor

@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 effectively addresses an issue where the widget previewer would crash when files in ephemeral directories were modified. The changes introduce logic to ignore file system events from these directories and from files not associated with an analysis context. This is a solid fix, complete with a new regression test. I have one minor suggestion to improve code clarity by removing a duplicated line.

Copy link
Contributor

@jyameo jyameo left a comment

Choose a reason for hiding this comment

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

LGTM!

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 13, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Nov 13, 2025
Merged via the queue into master with commit cfaaab8 Nov 13, 2025
151 checks passed
@auto-submit auto-submit bot deleted the fix_issue_178317 branch November 13, 2025 19:06
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 13, 2025
@bkonyi bkonyi added cp: beta cherry pick this pull request to beta release candidate branch cp: stable cherry pick this pull request to stable release candidate branch labels Nov 13, 2025
flutteractionsbot pushed a commit to flutteractionsbot/flutter that referenced this pull request Nov 13, 2025
…ries (flutter#178398)

The `flutter` tool creates various directories for ephemeral state while
executing commands. In some situations, these directories contain or
link to other Dart / Flutter projects with '.dart' sources or
'pubspec.yaml's. If these files change while the widget previewer is
active (e.g., due to a `flutter pub get` downloading and configuring new
plugins for the project), the previewer's directory watcher will detect
the change and attempt to analyze the source. This causes an exception
to be thrown by the analyzer as the modified file path does not have a
valid analysis context.

This change adds additional checks to the `PreviewDetector` that allow
for ignoring changes to `pubspec.yaml`s and `.dart` sources under known
ephemeral directories (e.g., build/,
linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't
associated with an analysis context.

Fixes flutter#178317
flutteractionsbot pushed a commit to flutteractionsbot/flutter that referenced this pull request Nov 13, 2025
…ries (flutter#178398)

The `flutter` tool creates various directories for ephemeral state while
executing commands. In some situations, these directories contain or
link to other Dart / Flutter projects with '.dart' sources or
'pubspec.yaml's. If these files change while the widget previewer is
active (e.g., due to a `flutter pub get` downloading and configuring new
plugins for the project), the previewer's directory watcher will detect
the change and attempt to analyze the source. This causes an exception
to be thrown by the analyzer as the modified file path does not have a
valid analysis context.

This change adds additional checks to the `PreviewDetector` that allow
for ignoring changes to `pubspec.yaml`s and `.dart` sources under known
ephemeral directories (e.g., build/,
linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't
associated with an analysis context.

Fixes flutter#178317
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 17, 2025
IvoneDjaja pushed a commit to IvoneDjaja/flutter that referenced this pull request Nov 22, 2025
…ries (flutter#178398)

The `flutter` tool creates various directories for ephemeral state while
executing commands. In some situations, these directories contain or
link to other Dart / Flutter projects with '.dart' sources or
'pubspec.yaml's. If these files change while the widget previewer is
active (e.g., due to a `flutter pub get` downloading and configuring new
plugins for the project), the previewer's directory watcher will detect
the change and attempt to analyze the source. This causes an exception
to be thrown by the analyzer as the modified file path does not have a
valid analysis context.

This change adds additional checks to the `PreviewDetector` that allow
for ignoring changes to `pubspec.yaml`s and `.dart` sources under known
ephemeral directories (e.g., build/,
linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't
associated with an analysis context.

Fixes flutter#178317
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
…ries (flutter#178398)

The `flutter` tool creates various directories for ephemeral state while
executing commands. In some situations, these directories contain or
link to other Dart / Flutter projects with '.dart' sources or
'pubspec.yaml's. If these files change while the widget previewer is
active (e.g., due to a `flutter pub get` downloading and configuring new
plugins for the project), the previewer's directory watcher will detect
the change and attempt to analyze the source. This causes an exception
to be thrown by the analyzer as the modified file path does not have a
valid analysis context.

This change adds additional checks to the `PreviewDetector` that allow
for ignoring changes to `pubspec.yaml`s and `.dart` sources under known
ephemeral directories (e.g., build/,
linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't
associated with an analysis context.

Fixes flutter#178317
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…ries (flutter#178398)

The `flutter` tool creates various directories for ephemeral state while
executing commands. In some situations, these directories contain or
link to other Dart / Flutter projects with '.dart' sources or
'pubspec.yaml's. If these files change while the widget previewer is
active (e.g., due to a `flutter pub get` downloading and configuring new
plugins for the project), the previewer's directory watcher will detect
the change and attempt to analyze the source. This causes an exception
to be thrown by the analyzer as the modified file path does not have a
valid analysis context.

This change adds additional checks to the `PreviewDetector` that allow
for ignoring changes to `pubspec.yaml`s and `.dart` sources under known
ephemeral directories (e.g., build/,
linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't
associated with an analysis context.

Fixes flutter#178317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cp: beta cherry pick this pull request to beta release candidate branch cp: stable cherry pick this pull request to stable release candidate branch tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ Widget Preview ] Running flutter pub get after adding a plugin dependency causes the previewer to crash

2 participants