Skip to content

Support some kind of --machine or --json mode for flutter widget-preview start #173545

Closed

Description

@DanTup

Currently the flutter widget-preview start command is geared around use in a terminal by a user:

PS D:\Dev\Test Projects\flutter_counter> flutter widget-preview start 
Creating widget preview scaffolding at: D:\Dev\Test Projects\flutter_counter\.dart_tool\widget_preview_scaffold
Creating the Widget Preview Scaffold manifest at D:\Dev\Test Projects\flutter_counter\.dart_tool\widget_preview_scaffold\preview_manifest.json
Finding previews in D:\Dev\Test Projects\flutter_counter...
Found 0 previews.
Launching the Widget Preview Scaffold...
Launching lib\main.dart on Chrome in debug mode...
Done loading previews.
This app is linked to the debug service: ws://127.0.0.1:61185/sEoFe2wAsf4=/ws
Debug service listening on ws://127.0.0.1:61185/sEoFe2wAsf4=/ws
Starting application from main method in: org-dartlang-app:/web_entrypoint.dart.
Detected change in D:\Dev\Test Projects\flutter_counter\lib\main.dart.

To help embed inside IDEs, it would be better to have some kind of structured interface so we can read the URLs (and perhaps capture logs etc.) without having to regex the output.

For some of the Flutter tools, there is a --machine flag, and these are usually things where we have two-way communication over stdin/stdout. I think for some Dart tools there is --json which is usually when the output is just one-way and the output is just wrapped in json (no stdin use).

I'm not sure what kind of APIs we might end up with between the editor and preview (and whether they should be direct like this, or over DTD or similar) so I don't know which solution would make most sense at this point.

cc @bkonyi

Activity

  1. added
    team-toolOwned by Flutter Tool team
    a: widget previewsIssues related to the Widget Previewer tooling
    on Aug 11, 2025
  2. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Aug 11, 2025
  3. DanTup commented on Aug 11, 2025

    @DanTup
    ContributorAuthor

    Oh also, in this mode (or with another flag), it should not automatically launch a browser (since we will be showing it in an iframe in the IDE).

    Edit: This exists, there's a --web-server/--no-web-server flag.

  4. added a commit that references this issue on Aug 12, 2025
  5. github-actions commented on Aug 28, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Aug 28, 2025
  7. self-assigned this
    on Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: widget previewsIssues related to the Widget Previewer toolingr: fixedIssue is closed as already fixed in a newer versionteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions