Skip to content

[ Widget Preview ] Crash when adding or removing a pubspec.yaml from a subdirectory #179155

Closed

Description

@bkonyi

When adding or removing a pubspec.yaml while the widget previewer is running, it's possible to encounter the following crash:

Thread 0 main threadStateError: Bad state: No element
at ListBase.firstWhere(list.dart:132)
at PreviewManifest._calculatePubspecHashes(preview_manifest.dart:69)
at PreviewManifest.updatePubspecHash(preview_manifest.dart:146)
at PreviewPubspecBuilder.populatePreviewPubspec(preview_pubspec_builder.dart:174)
at <asynchronous gap>(async)

An example of this situation is a user creating a new workspace project in the previewed directory. The preview detection logic sees that a pubspec.yaml has been updated and attempts to update its hash code in the preview manifest. This is done by trying to find the first FlutterProject which has a pubspec at the location of the new pubspec.yaml. Since this project is new, the previewer isn't aware of it and the firstWhere(...) call throws since there's no match.

Activity

  1. self-assigned this
    on Nov 26, 2025
  2. added
    P1High-priority issues at the top of the work list
    team-toolOwned by Flutter Tool team
    triaged-toolTriaged by Flutter Tool team
    a: widget previewsIssues related to the Widget Previewer tooling
    on Nov 26, 2025
  3. github-actions commented on Dec 11, 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.

  4. locked as resolved and limited conversation to collaborators on Dec 11, 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 toolingteam-toolOwned by Flutter Tool teamtriaged-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