[ Widget Preview ] Don't try to instantiate invalid @Preview() applications#173984
Merged
auto-submit[bot] merged 3 commits intomasterfrom Aug 18, 2025
Merged
[ Widget Preview ] Don't try to instantiate invalid @Preview() applications#173984auto-submit[bot] merged 3 commits intomasterfrom
@Preview() applications#173984auto-submit[bot] merged 3 commits intomasterfrom
Conversation
…ications Applying `@Preview()` to an invalid AST node shouldn't cause the preview environment to throw an exception due to invalid generated code. This change adds some additional checks to ensure that invalid `@Preview()` applications are ignored. Related issue: #173959 Related stable hotfix: #173979
Contributor
There was a problem hiding this comment.
Code Review
This pull request enhances the robustness of widget preview detection by adding checks to ignore invalid @Preview() applications, preventing exceptions from invalid generated code. The changes are logical and well-tested. I've added a couple of suggestions to further improve the resilience of the AST parsing by handling nullable return types and unexpected type annotations more safely, which aligns with the goal of this PR.
packages/flutter_tools/lib/src/widget_preview/dependency_graph.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/widget_preview/dependency_graph.dart
Outdated
Show resolved
Hide resolved
matanlurey
approved these changes
Aug 18, 2025
Contributor
|
autosubmit label was removed for flutter/flutter/173984, because - The status or check suite Mac tool_integration_tests_4_5 has failed. Please fix the issues identified (or deflake) before re-applying this label. |
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Aug 19, 2025
auto-submit bot
pushed a commit
to flutter/packages
that referenced
this pull request
Aug 19, 2025
flutter/flutter@2265d94...e65380a 2025-08-19 [email protected] Roll Dart SDK from 502455ee300b to 9105d946af95 (3 revisions) (flutter/flutter#174002) 2025-08-18 [email protected] Add `open_jdk` to `Linux analyze` (flutter/flutter#173988) 2025-08-18 [email protected] Add "team-ios" label to iOS team triage query (flutter/flutter#173997) 2025-08-18 [email protected] Migrate deeplink json creation to public AGP api (flutter/flutter#173794) 2025-08-18 [email protected] [ Widget Preview ] Don't crash when directory watcher restarts on Windows (flutter/flutter#173987) 2025-08-18 [email protected] [ Widget Preview ] Don't try to instantiate invalid `@Preview()` applications (flutter/flutter#173984) 2025-08-18 [email protected] Explain how to run Google Test tests directly (flutter/flutter#173978) 2025-08-18 [email protected] [flutter_tools] Use DWDS 25.0.1 (flutter/flutter#173777) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
WillBLogical
pushed a commit
to WillBLogical/packages
that referenced
this pull request
Aug 20, 2025
flutter/flutter@2265d94...e65380a 2025-08-19 [email protected] Roll Dart SDK from 502455ee300b to 9105d946af95 (3 revisions) (flutter/flutter#174002) 2025-08-18 [email protected] Add `open_jdk` to `Linux analyze` (flutter/flutter#173988) 2025-08-18 [email protected] Add "team-ios" label to iOS team triage query (flutter/flutter#173997) 2025-08-18 [email protected] Migrate deeplink json creation to public AGP api (flutter/flutter#173794) 2025-08-18 [email protected] [ Widget Preview ] Don't crash when directory watcher restarts on Windows (flutter/flutter#173987) 2025-08-18 [email protected] [ Widget Preview ] Don't try to instantiate invalid `@Preview()` applications (flutter/flutter#173984) 2025-08-18 [email protected] Explain how to run Google Test tests directly (flutter/flutter#173978) 2025-08-18 [email protected] [flutter_tools] Use DWDS 25.0.1 (flutter/flutter#173777) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
gmackall
pushed a commit
to gmackall/flutter
that referenced
this pull request
Aug 21, 2025
…ications (flutter#173984) Applying `@Preview()` to an invalid AST node shouldn't cause the preview environment to throw an exception due to invalid generated code. This change adds some additional checks to ensure that invalid `@Preview()` applications are ignored. Related issue: flutter#173959 Related stable hotfix: flutter#173979
SydneyBao
pushed a commit
to SydneyBao/flutter
that referenced
this pull request
Aug 22, 2025
…ications (flutter#173984) Applying `@Preview()` to an invalid AST node shouldn't cause the preview environment to throw an exception due to invalid generated code. This change adds some additional checks to ensure that invalid `@Preview()` applications are ignored. Related issue: flutter#173959 Related stable hotfix: flutter#173979
SydneyBao
pushed a commit
to SydneyBao/flutter
that referenced
this pull request
Aug 22, 2025
…ications (flutter#173984) Applying `@Preview()` to an invalid AST node shouldn't cause the preview environment to throw an exception due to invalid generated code. This change adds some additional checks to ensure that invalid `@Preview()` applications are ignored. Related issue: flutter#173959 Related stable hotfix: flutter#173979
mboetger
pushed a commit
to mboetger/flutter
that referenced
this pull request
Sep 18, 2025
…ications (flutter#173984) Applying `@Preview()` to an invalid AST node shouldn't cause the preview environment to throw an exception due to invalid generated code. This change adds some additional checks to ensure that invalid `@Preview()` applications are ignored. Related issue: flutter#173959 Related stable hotfix: flutter#173979
korca0220
pushed a commit
to korca0220/flutter
that referenced
this pull request
Sep 22, 2025
…ications (flutter#173984) Applying `@Preview()` to an invalid AST node shouldn't cause the preview environment to throw an exception due to invalid generated code. This change adds some additional checks to ensure that invalid `@Preview()` applications are ignored. Related issue: flutter#173959 Related stable hotfix: flutter#173979
Jaineel-Mamtora
pushed a commit
to Jaineel-Mamtora/flutter_forked
that referenced
this pull request
Sep 24, 2025
…ications (flutter#173984) Applying `@Preview()` to an invalid AST node shouldn't cause the preview environment to throw an exception due to invalid generated code. This change adds some additional checks to ensure that invalid `@Preview()` applications are ignored. Related issue: flutter#173959 Related stable hotfix: flutter#173979
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Nov 12, 2025
lucaantonelli
pushed a commit
to lucaantonelli/flutter
that referenced
this pull request
Nov 21, 2025
…ications (flutter#173984) Applying `@Preview()` to an invalid AST node shouldn't cause the preview environment to throw an exception due to invalid generated code. This change adds some additional checks to ensure that invalid `@Preview()` applications are ignored. Related issue: flutter#173959 Related stable hotfix: flutter#173979
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Applying
@Preview()to an invalid AST node shouldn't cause the preview environment to throw an exception due to invalid generated code.This change adds some additional checks to ensure that invalid
@Preview()applications are ignored.Related issue: #173959
Related stable hotfix: #173979