Skip to content

[widget-preview] Preview crashes when project uses dependancy that requires web setup #179577

Closed

Description

@zddarova

Steps to reproduce

  1. Create new Flutter Project
  2. Add widget previews to any widget
  3. Add passkeys dependency to the project
  4. Run flutter widget-preview start

Expected results

Widget preview should open in a browser or communicate error properly for easier resolution from developer side. Maybe there is a way to copy web setup from project where preview is used

Actual results

widget_preview_scaffold uses project as dependency, therefore passkeys added as transitive dependency. It could be properly setup in original project, but it is not gonna be setup in widget_preview_scaffold, so when using previews, it crashes with error

Error: Passkeys Web SDK not loaded. Please include the Passkeys Web SDK (bundle.js) in your
HTML file. You can find it on
https://github.com/corbado/flutter-passkeys/releases/download/2.4.0/bundle.js

Adding Passkeys Web SDK to project's index.html is not working, because issue in index.html in widget_preview_scaffold.
When adding SDK there, there is a need to add that html file to git, because otherwise it will be reset after running flutter clean. And as far as i understand this workaround should not work after #179039, so the solution would be to add it there manually whenever it resets.

Maybe it can be classified as a package issue, but from frameworks side there is little information on whats going on and it required tricky workaround

Code sample

Code sample

https://github.com/zddarova/widget_preview_passkey_sample

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs

https://github.com/zddarova/widget_preview_passkey_sample/blob/main/logs.txt

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.38.3, on macOS 26.1 25B78 darwin-arm64, locale en-UA) [3.1s]
    • Flutter version 3.38.3 on channel stable at /Users/zddarova/.asdf/installs/flutter/3.38.3-stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 19074d12f7 (3 weeks ago), 2025-11-20 17:53:13 -0500
    • Engine revision 13e658725d
    • Dart version 3.10.1
    • DevTools version 2.51.1
    • 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, enable-uiscene-migration

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [6.8s]
    • Android SDK at /Users/zddarova/Library/Android/sdk
    • Emulator version 36.2.12.0 (build_id 14214601) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/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.8+-14196175-b1038.72)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.1.1) [3.9s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17B100
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [8ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (3 available) [6.1s]
    • macOS (desktop)                     • macos                     • darwin-arm64   • macOS 26.1 25B78 darwin-arm64
    • Chrome (web)                        • chrome                    • web-javascript • Google Chrome 142.0.7444.176

[✓] Network resources [1,344ms]
    • All expected network resources are available.

• No issues found!

Activity

  1. zddarova commented on Dec 8, 2025

    @zddarova
    Author

    as a workaround, i added preview's index.html to git by calling

    git add .dart_tool/widget_preview_scaffold/web/index.html -f

    and added there a Passkey SDK

    index.html
    <!DOCTYPE html>
    <html>
    <head>
      <!--
        If you are serving your web app in a path other than the root, change the
        href value below to reflect the base path you are serving from.
    
        The path provided below has to start and end with a slash "/" in order for
        it to work correctly.
    
        For more details:
        * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
    
        This is a placeholder for base href that will be replaced by the value of
        the `--base-href` argument provided to `flutter build`.
      -->
      <base href="$FLUTTER_BASE_HREF">
    
      <meta charset="UTF-8">
      <meta content="IE=Edge" http-equiv="X-UA-Compatible">
      <meta name="description" content="">
    
      <!-- iOS meta tags & icons -->
      <meta name="mobile-web-app-capable" content="yes">
      <meta name="apple-mobile-web-app-status-bar-style" content="black">
      <meta name="apple-mobile-web-app-title" content="widget_preview_scaffold">
      <link rel="apple-touch-icon" href="icons/Icon-192.png">
    
      <!-- Favicon -->
      <link rel="icon" type="image/png" href="favicon.png"/>
    
      <title>widget_preview_scaffold</title>
      <link rel="manifest" href="manifest.json">
    </head>
    <body>
    
          <!-- Passkeys Web SDK -->
      <script type="application/javascript" src="https://github.com/corbado/flutter-passkeys/releases/download/2.4.0/bundle.js"></script>
    
      <script src="flutter_bootstrap.js" async></script>
    </body>
    </html>
  2. changed the title [-][widget-preview] Preview crashes over Passkey[/-] [+][widget-preview] Preview crashes when project uses dependancy that requires web setup[/+] on Dec 8, 2025
  3. tirth-patel-nc commented on Dec 9, 2025

    @tirth-patel-nc
    Member

    Thanks for the report. Seeing the same behaviour with latest SDK versions.

    stable : 3.38.4
    master : 3.40.0-1.0.pre-77
    
  4. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    platform-webWeb applications specifically
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    workaround availableThere is a workaround available to overcome the issue
    team-toolOwned by Flutter Tool team
    a: widget previewsIssues related to the Widget Previewer tooling
    c: crashStack traces logged to the console
    and removed
    in triagePresently being triaged by the triage team
    on Dec 9, 2025
  5. self-assigned this
    on Dec 9, 2025
  6. bkonyi commented on Dec 9, 2025

    @bkonyi
    Contributor

    Thanks for filing this @zddarova! I really appreciate you providing the reproduction information and sample project, it's very helpful.

    I just took a look at the project, and I notice that the only reference to passkeys is in the pubspec, but not in the actual project code. I just want to confirm that's expected as I would have thought that, in this situation, the passkeys logic would not be included in the compiled application at all.

    Looking at package:passkeys_web, I see that the plugin author has decided to close the window if the bundle.js isn't detected. That's not great, and it'd probably be better if they just printed a warning and let runtime errors be thrown (the widget previewer would likely handle them and display the errors in place of individual previews). However, that's obviously not something that projects depending on that package can control.

    I think I'll need to investigate:

    1. Why a web plugin is trying to initialize if it's not actually referenced anywhere in the project.
    2. If we should be providing a way to configure the widget_preview_scaffold with custom state (e.g., adding entries to index.html).

    Plugin support for widget previews is effectively best-effort (if they work, they work, if not, 🤷), but the presence of plugin dependencies shouldn't prevent the widget previewer from running.

  7. added
    P2Important issues not at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    on Dec 9, 2025
  8. zddarova commented on Dec 9, 2025

    @zddarova
    Author

    Yes, that’s correct — the passkeys package was added as a dependency, but it’s not used anywhere in the project code.

  9. RamiroEda commented on Dec 18, 2025

    @RamiroEda

    The same issue occurs with pdfx package.

    Error: Assertion failed: file:///[...]/.pub-cache/hosted/pub.dev/pdfx-2.9.2/lib/src/renderer/web/platform.dart:29:9
    checkPdfjsLibInstallation()
    "pdf.js not added in web/index.html. Run «flutter pub run pdfx:install_web» or add script manually"
    

    This is because the generated index.html file doesn't have the required scripts.

  10. added
    ⏳Bot is counting down the days until it unassigns the issue
    on Apr 14, 2026
  11. flutter-triage-bot commented on Apr 14, 2026

    @flutter-triage-bot

    This issue is assigned to @bkonyi but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

  12. github-actions commented on Jul 14, 2026

    @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.

  13. locked as resolved and limited conversation to collaborators on Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

⏳Bot is counting down the days until it unassigns the issueP2Important issues not at the top of the work lista: widget previewsIssues related to the Widget Previewer toolingc: crashStack traces logged to the consolefound in release: 3.38Found to occur in 3.38found in release: 3.40Found to occur in 3.40has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool teamworkaround availableThere is a workaround available to overcome the issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions