Skip to content

Support multiple (unrelated) Flutter projects in the same workspace for Widget Preview #5671

Open

Description

@DanTup

Splitting this from #5649

Currently we arbitrarily pick the first Flutter project when there are multiple in the project to show the preview for. This feels like a bad limitation (particularly if you have example projects).

It's blocked on flutter/flutter#173550 for now (unless we decide to handle this client-side, but I don't feel like that's the right approach).

Activity

  1. added this to the v3.120.0 milestone on Aug 28, 2025
  2. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    in flutterRelates to running Flutter apps
    on Aug 28, 2025
  3. modified the milestones: v3.120.0, v3.122.0 on Sep 17, 2025
  4. modified the milestones: v3.122.0, v3.124.0 on Oct 17, 2025
  5. GabrielRStabile commented on Oct 30, 2025

    @GabrielRStabile

    Hey @DanTup, I'm experiencing a similar issue with Widget Preview when using Flutter beta in VS Code. In my case, only the widget previews from my main project are being recognized, while previews from other packages are not detected.

    My app uses a monolithic structure where there's a app folder with the main Flutter project initialized, and additional folders containing Flutter packages without a main.dart file. These packages are linked using a Dart workspace. I believe this scenario is different from the example folder case mentioned in the issue description, since example folders typically contain a separate Flutter app with its own entry point.

    Interestingly, when I run the flutter widget-preview start command from the terminal at the workspace root, it correctly detects and displays previews from all packages across the workspace.

    This suggests that the VS Code extension might be limiting preview detection to only the first/main Flutter project in the workspace, while the CLI command properly handles the workspace structure and discovers previews in all packages.

    Logs from Flutter Widget Preview on VS Code

    Dart Code extension: 3.120.1
    Flutter extension: 3.120.0 (not activated)

    App: Visual Studio Code
    App Host: desktop
    Version: mac 1.105.1

    Logging Categories:
    FlutterWidgetPreview

    Thu Oct 30 2025 [05:58:06 GMT-0300 (Horário Padrão de Brasília)] Log file started
    [05:58:07] [FlutterWidgetPreview] [Info] Spawning /Users/user/.puro/envs/beta/flutter/bin/flutter with args ["widget-preview","start","--machine","--web-server","--dtd-url","ws://127.0.0.1:58285/el18DR_yrSg=","--devtools-server-address","http://127.0.0.1:9100/"]
    [05:58:07] [FlutterWidgetPreview] [Info] .. in /Users/user/dart-workspace-root-folder/app
    [05:58:07] [FlutterWidgetPreview] [Info] .. with {"toolEnv":{"FLUTTER_HOST":"VSCode","PUB_ENVIRONMENT":"vscode.dart-code","FLUTTER_ROOT":"/Users/user/.puro/envs/beta/flutter"}}
    [05:58:07] [FlutterWidgetPreview] [Info] PID: 132
    [05:58:15] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.logMessage","params":{"level":"warning","message":"Waiting for another flutter command to release the startup lock..."}}]
    [05:58:15] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.initializing","params":{"pid":352}}]
    [05:58:15] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.logMessage","params":{"level":"status","message":"Finding previews in /Users/user/dart-workspace-root-folder/app..."}}]
    [05:59:00] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.logMessage","params":{"level":"status","message":"Found 6 previews."}}]
    [05:59:01] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.logMessage","params":{"level":"status","message":"Launching the Widget Preview Scaffold on Web Server..."}}]
    [05:59:02] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.logMessage","params":{"level":"status","message":"Launching lib/main.dart on Web Server in debug mode..."}}]
    [05:59:02] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.logMessage","params":{"level":"status","message":"Waiting for connection from debug service on Web Server..."}}]
    [05:59:31] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.logMessage","params":{"level":"status","message":"lib/main.dart is being served at http://localhost:58434"}}]
    [05:59:31] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.logMessage","params":{"level":"status","message":"The web-server device requires the Dart Debug Chrome extension for debugging. Consider using the Chrome or Edge devices for an improved development workflow."}}]
    [05:59:31] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.app.webLaunchUrl","params":{"url":"http://localhost:58434","launched":false}}]
    [05:59:31] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.started","params":{"url":"http://localhost:58434"}}]
    [05:59:31] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.logMessage","params":{"level":"status","message":"Done loading previews."}}]

    Flutter Doctor

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel beta, 3.38.0-0.1.pre, on macOS 26.0.1 25A362 darwin-arm64, locale pt-BR)
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    [✓] Xcode - develop for iOS and macOS (Xcode 26.0)
    [✓] Chrome - develop for the web
    [✓] Connected device (3 available)
    [✓] Network resources

    • No issues found!

  6. changed the title [-]Support multiple Flutter projects in the same workspace for Widget Preview[/-] [+]Support multiple distinct Flutter projects in the same workspace for Widget Preview[/+] on Oct 30, 2025
  7. changed the title [-]Support multiple distinct Flutter projects in the same workspace for Widget Preview[/-] [+]Support multiple (unrelated) Flutter projects in the same workspace for Widget Preview[/+] on Oct 30, 2025
  8. DanTup commented on Oct 30, 2025

    @DanTup
    MemberAuthor

    Ah, thanks for the ping. It is a known limitation that we only support this for one "project", however I didn't realise we weren't handling Pub workspaces correctly (which should work). I've opened #5775 to track that separately from this (which is about unrelated projects). Thanks!

  9. modified the milestones: v3.124.0, On Deck on Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked on dart / flutterRequires a change in Dart or Flutter to progressin flutterRelates to running Flutter appsin flutter widget previewRelates to the embedded Flutter widget previewis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions