Skip to content

Conversation

@bkonyi
Copy link
Contributor

@bkonyi bkonyi commented Jul 2, 2025

Updates the widget previewer to properly handle previews defined across a workspace. This is effectively equivalent to displaying previews from multiple individual projects, which required a fairly significant rework to properly support:

  • resolving asset paths to the right project
  • loading assets across projects in the workspace
  • tracking changes to pubspec.yaml files across the workspace

While making this change, it became apparent that we don't need to explicitly list the assets from the various projects explicitly in the scaffold's pubspec.yaml as they're automatically pulled in by adding those project's as dependencies and using the package/$ASSET_PATH format to load the assets from the scaffold. This allowed for the removal of a significant amount of logic related to building the scaffold's pubspec.

Fixes #169268

Updates the widget previewer to properly handle previews defined across
a workspace. This is effectively equivalent to displaying previews from
multiple individual projects, which required a fairly significant rework
to properly support:

 - resolving asset paths to the right project
 - loading assets across projects in the workspace
 - tracking changes to pubspec.yaml files across the workspace

While making this change, it became apparent that we don't need to
explicitly list the assets from the various projects explicitly in the
scaffold's pubspec.yaml as they're automatically pulled in by adding
those project's as dependencies and using the `package/$ASSET_PATH`
format to load the assets from the scaffold. This allowed for the
removal of a significant amount of logic related to building the
scaffold's pubspec.

Fixes #169268
@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jul 2, 2025
import '../../src/common.dart';
import '../../src/context.dart';

// TODO(bkonyi): test pubspec change detection for workspaces
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests should be rewritten to utilize some of the utilities that have been added for testing widget preview projects. I'll do this in a follow up to avoid making this PR even larger.

@bkonyi bkonyi requested a review from jyameo July 2, 2025 18:25
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.

Overall LGTM! However, there are some test failures to note:

  • UnimplementedError: workspaceProjects in widget_preview_test.dart.
  • Mismatches between expected and actual URI/path formats in preview_detector_graph_test.dart.

@bkonyi
Copy link
Contributor Author

bkonyi commented Jul 3, 2025

Overall LGTM! However, there are some test failures to note:

  • UnimplementedError: workspaceProjects in widget_preview_test.dart.
  • Mismatches between expected and actual URI/path formats in preview_detector_graph_test.dart.

I swear I had run all the widget preview tests before uploading this... apparently not 😅 The failures should be fixed now.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 3, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Jul 3, 2025
Merged via the queue into master with commit 750b87f Jul 3, 2025
145 of 146 checks passed
@auto-submit auto-submit bot deleted the widget_previews_workspace_support branch July 3, 2025 18:37
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 7, 2025
mboetger pushed a commit to mboetger/flutter that referenced this pull request Jul 21, 2025
Updates the widget previewer to properly handle previews defined across
a workspace. This is effectively equivalent to displaying previews from
multiple individual projects, which required a fairly significant rework
to properly support:

 - resolving asset paths to the right project
 - loading assets across projects in the workspace
 - tracking changes to pubspec.yaml files across the workspace

While making this change, it became apparent that we don't need to
explicitly list the assets from the various projects explicitly in the
scaffold's pubspec.yaml as they're automatically pulled in by adding
those project's as dependencies and using the `package/$ASSET_PATH`
format to load the assets from the scaffold. This allowed for the
removal of a significant amount of logic related to building the
scaffold's pubspec.

Fixes flutter#169268
azatech pushed a commit to azatech/flutter that referenced this pull request Jul 28, 2025
Updates the widget previewer to properly handle previews defined across
a workspace. This is effectively equivalent to displaying previews from
multiple individual projects, which required a fairly significant rework
to properly support:

 - resolving asset paths to the right project
 - loading assets across projects in the workspace
 - tracking changes to pubspec.yaml files across the workspace

While making this change, it became apparent that we don't need to
explicitly list the assets from the various projects explicitly in the
scaffold's pubspec.yaml as they're automatically pulled in by adding
those project's as dependencies and using the `package/$ASSET_PATH`
format to load the assets from the scaffold. This allowed for the
removal of a significant amount of logic related to building the
scaffold's pubspec.

Fixes flutter#169268
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
lucaantonelli pushed a commit to lucaantonelli/flutter that referenced this pull request Nov 21, 2025
Updates the widget previewer to properly handle previews defined across
a workspace. This is effectively equivalent to displaying previews from
multiple individual projects, which required a fairly significant rework
to properly support:

 - resolving asset paths to the right project
 - loading assets across projects in the workspace
 - tracking changes to pubspec.yaml files across the workspace

While making this change, it became apparent that we don't need to
explicitly list the assets from the various projects explicitly in the
scaffold's pubspec.yaml as they're automatically pulled in by adding
those project's as dependencies and using the `package/$ASSET_PATH`
format to load the assets from the scaffold. This allowed for the
removal of a significant amount of logic related to building the
scaffold's pubspec.

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

Labels

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] Generated Scaffold project doesn't work with pub workspaces

2 participants