Skip to content

Conversation

@flutteractionsbot
Copy link

@flutteractionsbot flutteractionsbot commented Nov 13, 2025

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:

What is the link to the issue this cherry-pick is addressing?

#178317

Changelog Description:

Explain this cherry pick in one line that is accessible to most Flutter developers. See best practices for examples

Running flutter pub get can crash the widget previewer when plugin dependencies are added or updated.

Impact Description:

What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch)

The widget previewer can crash when flutter pub get is run and causes plugins to be updated or added to the project. IDEs regularly run flutter pub get and automatically start up the widget previewer, making this the top tool crasher for 3.38. Also, when an IDE-managed widget previewer crashes, it silently dies without any indication to the user as the preview environment continues to work but will no longer hot reload when the user makes changes to their sources.

Workaround:

Is there a workaround for this issue?

  1. Run flutter pub get
  2. Start / restart the IDE

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:

What are the steps to validate that this fix works?

  1. Run flutter widget-preview start in a Flutter project
  2. Add a plugin dependency to the project's pubspec.yaml
  3. Run flutter pub get in the project, which should not cause the flutter widget-preview start process to crash

…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 flutteractionsbot added the cp: review Cherry-picks in the review queue label Nov 13, 2025
@flutteractionsbot
Copy link
Author

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

@flutter-dashboard
Copy link

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.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Nov 13, 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 introduces a mechanism to ignore file modifications within ephemeral directories for the widget preview feature. This is achieved by adding a new ephemeralDirectories property to FlutterProject and using it in PreviewDetector to filter out file system events. The implementation also includes refactoring to pass the FlutterProject instance to PreviewDetector and adds a new regression test to verify the behavior.

My main feedback is on the implementation of the path checking logic in PreviewDetector, which could be made more robust by using path-aware comparison methods instead of simple string containment. This will prevent potential false positives where valid source files might be ignored.

@reidbaker reidbaker added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 17, 2025
@auto-submit auto-submit bot merged commit 7e4b2a4 into flutter:flutter-3.38-candidate.0 Nov 17, 2025
146 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 20, 2025
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 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