Skip to content

Widget Preview terminates with "is not a valid Flutter project" for valid Flutter project #178052

Closed

Description

@DanTup

Steps to reproduce

I cloned the flutter/packages repo and opened it in VS Code, and got a notification that the widget preview server terminated. In the logs I found:

[4:04:03 PM] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.logMessage","params":{"level":"error","message":"D:\\Dev\\Google\\Flutter\\packages\\packages\\animations is not a valid Flutter project."}}]
[4:04:03 PM] [FlutterWidgetPreview] [Info] Process D:\Dev\Google\Flutter\Flutter main\bin\flutter.bat terminated! 1, null

It certainly looks like a valid Flutter project to me. My guess is that this might be because I haven't yet run pub get for this package, and therefore there are bits missing. However, since this is not an uncommon case, I think it needs to be handled (ideally in the tool here, to avoid IDEs having to do this kind of detailed tracking of the state of the Flutter projects).

cc @bkonyi

Expected results

The preview server should start up and just provide no widget previews (and pick up the previews once the project becomes in a state where this is possible).

Actual results

The server terminates with an error.

Code sample

Code sample

N/A

Screenshots or Video

Screenshots / Video demonstration

N/A

Logs

Logs
Wed Nov 05 2025 [16:04:01 GMT+0000 (Greenwich Mean Time)] Log file started
[4:04:02 PM] [FlutterWidgetPreview] [Info] Spawning D:\Dev\Google\Flutter\Flutter main\bin\flutter.bat with args ["widget-preview","start","--machine","--web-server","--dtd-url","ws://127.0.0.1:52532/CsKolHD-nZg=","--devtools-server-address","http://127.0.0.1:9100/"]
[4:04:02 PM] [FlutterWidgetPreview] [Info] ..  in D:\Dev\Google\Flutter\packages\packages\animations
[4:04:02 PM] [FlutterWidgetPreview] [Info] ..  with {"toolEnv":{"FLUTTER_HOST":"VSCode","PUB_ENVIRONMENT":"vscode.dart-code","FLUTTER_ROOT":"D:\\Dev\\Google\\Flutter\\Flutter main"}}
[4:04:02 PM] [FlutterWidgetPreview] [Info]     PID: 22732
[4:04:03 PM] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.initializing","params":{"pid":13596}}]
[4:04:03 PM] [FlutterWidgetPreview] [Info] <== [{"event":"widget_preview.logMessage","params":{"level":"error","message":"D:\\Dev\\Google\\Flutter\\packages\\packages\\animations is not a valid Flutter project."}}]
[4:04:03 PM] [FlutterWidgetPreview] [Info] Process D:\Dev\Google\Flutter\Flutter main\bin\flutter.bat terminated! 1, null
[4:04:03 PM] [General] [Error] Failed to set up Widget Preview: Widget Preview server process terminated

Flutter Doctor output

Doctor output
PS D:\Dev\Google\Flutter\packages\packages\animations> flutter doctor -v
[!] Flutter (Channel master, 3.38.0-1.0.pre-38, on Microsoft Windows [Version 10.0.26100.6899], locale en-GB) [3.3s]
    • Flutter version 3.38.0-1.0.pre-38 on channel master at D:\Dev\Google\Flutter\Flutter main
    ! Warning: `dart` on your path resolves to D:\Tools\Dart\Stable\bin\dart.exe, which is not inside your current Flutter SDK checkout at
      D:\Dev\Google\Flutter\Flutter main. Consider adding D:\Dev\Google\Flutter\Flutter main\bin to the front of your path.
    ! Upstream repository [email protected]:DanTup/flutter.git is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to [email protected]:DanTup/flutter.git to dismiss this error.
    • Framework revision 498545a341 (4 weeks ago), 2025-10-09 17:34:03 -0500
    • Engine revision d64282028b
    • Dart version 3.11.0 (build 3.11.0-8.0.dev)
    • DevTools version 2.51.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations,
      enable-native-assets, omit-legacy-version-file, enable-lldb-debugging
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and
      upgrades.

[✓] Windows Version (11 Pro 64-bit, 24H2, 2009) [652ms]

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.1s]
    • Android SDK at C:\Users\danny\AppData\Local\Android\sdk
    • Emulator version 35.4.9.0 (build_id 13025442) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Chrome - develop for the web [54ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.5) [53ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.10.35122.118
    • Windows 10 SDK version 10.0.26100.0

[✓] Connected device (3 available) [105ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.6899]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 142.0.7444.60
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 141.0.3537.92

[✓] Network resources [269ms]
    • All expected network resources are available.

! Doctor found issues in 2 categories.
PS D:\Dev\Google\Flutter\packages\packages\animations>

Activity

  1. tirth-patel-nc commented on Nov 6, 2025

    @tirth-patel-nc
    Member

    @DanTup thanks for the report. I noticed this while switching flutter versions in VSCode.

    stable : 3.35.7
    master : 3.38.0-1.0.pre-439
    

    Failed to set up Widget Preview: Widget Preview server process terminated

    Image

    Failed to set up Widget Preview: Error: View provider for 'sidebarWidgetPreview' already registered

    Image
    Screen.Recording.2025-11-06.at.3.32.25.PM.mov
  2. added
    c: crashStack traces logged to the console
    toolAffects the "flutter" command-line tool. See also t: labels.
    team-toolOwned by Flutter Tool team
    a: widget previewsIssues related to the Widget Previewer tooling
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Nov 6, 2025
  3. DanTup commented on Nov 6, 2025

    @DanTup
    ContributorAuthor

    @tirth-patel-nc thanks - the second issue you hit ("already registered") looks like a bug in Dart-Code - I've filed Dart-Code/Dart-Code#5782 for that one. Thanks!

  4. bkonyi commented on Nov 6, 2025

    @bkonyi
    Contributor

    Good catch @DanTup! I think this check can actually just be removed. It shouldn't matter if there's a .dart_tool directory or if pub get hasn't been run since the widget_preview_scaffold project will have pub get run when we launch the previewer.

    I'll upload a fix and CP this.

  5. self-assigned this
    on Nov 6, 2025
  6. added
    P1High-priority issues at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    on Nov 6, 2025
  7. 3 remaining items

  8. DanTup commented on Nov 11, 2025

    @DanTup
    ContributorAuthor

    @bkonyi thanks! Do you still intend to cherry-pick?

  9. tirth-patel-nc commented on Nov 21, 2025

    @tirth-patel-nc
    Member
    Screen.Recording.2025-11-21.at.5.17.53.PM.mov

    Issue is still present on latest master 3.39.0-1.0.pre-227. cc: @huycozy

  10. DanTup commented on Nov 21, 2025

    @DanTup
    ContributorAuthor

    @tirth-patel-nc looking at the video, I think you're seeing Dart-Code/Dart-Code#5782 and not the issue fixed here?

    A fix for that is currently live in the pre-release version of the Dart VS Code extension and will be included in the stable release at the end of the month.

  11. github-actions commented on Dec 10, 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.

  12. locked as resolved and limited conversation to collaborators on Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: widget previewsIssues related to the Widget Previewer toolingc: crashStack traces logged to the consolefound in release: 3.35Found to occur in 3.35found in release: 3.38Found to occur in 3.38has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions