Skip to content

[ Widget Preview ] Running flutter pub get after adding a plugin dependency causes the previewer to crash #178317

Description

@bkonyi

To reproduce:

  • Run flutter widget-preview start --web-server in a Flutter project directory
  • Add a plugin package dependency to the pubspec.yaml
  • Run flutter pub get

This will cause the flutter widget-preview process to repeatedly crash with an exception similar to the following:

Oops; flutter has exited unexpectedly: "Bad state: Unable to find the context to
/Users/bkonyi/samples/background_isolate_channels/linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux/test/shared_preferences_linux_async_test.dart".

Stack trace:

#0      AnalysisContextCollectionImpl.contextFor (package:analyzer/src/dart/analysis/analysis_context_collection.dart:177:5)
#1      PreviewDetector._onFileSystemEvent.<anonymous closure> (package:flutter_tools/src/widget_preview/preview_detector.dart:147:50)
#2      PreviewDetectorMutex.runGuarded (package:flutter_tools/src/widget_preview/utils.dart:99:35)
<asynchronous suspension>
#3      PreviewDetector._onFileSystemEvent (package:flutter_tools/src/widget_preview/preview_detector.dart:118:5)
<asynchronous suspension>

Activity

  1. self-assigned this
    on Nov 11, 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 11, 2025
  3. bkonyi commented on Nov 12, 2025

    @bkonyi
    ContributorAuthor

    This issue can be worked around by executing flutter pub get after updating Flutter or adding / updating dependencies to a project and then restarting the widget previewer. For IDE users, this simply requires restarting the IDE.

  4. github-actions commented on Nov 27, 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.

  5. locked as resolved and limited conversation to collaborators on Nov 27, 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