用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill flutter-widget-previewer命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | flutter-widget-previewer |
| description | >- Use when this capability is needed. |
Enable live widget previews (Chrome or IDE “Flutter Widget Preview” tab) separate from a full app, using the @Preview annotation and the flutter widget-preview CLI.
Official reference: Flutter Widget Previewer
@Preview to functions or widgets.flutter widget-preview start from a project root.dart:io / dart:ffi in the previewed tree).size, brightness, theme, wrapper, MultiPreview).package:flutter/widget_previews.dart and package:flutter/material.dart (or Cupertino) as needed.From the Flutter package or app root:
flutter widget-preview start
Launches a local server and opens a Widget Preview environment in Chrome; updates follow project changes.
IDE: Android Studio / IntelliJ / VS Code can show “Flutter Widget Preview” in the sidebar (may auto-start on launch per doc).
@Preview applies to:
Widget or WidgetBuilder.Widget or WidgetBuilder.Widget constructors or factories with no required arguments.Minimal example:
import 'package:flutter/widget_previews.dart';
import 'package:flutter/material.dart';
@Preview(name: 'My Sample Text')
Widget mySampleText() {
return const Text('Hello, World!');
}
name: Label in the preview list.group: Groups related previews.size: Size(width, height) — prefer explicit constraints; unconstrained widgets may get ~half previewer size (behavior may change).@Preview(name: 'Light', brightness: Brightness.light)
@Preview(name: 'Dark', brightness: Brightness.dark)
Widget myButtonPreview() => const ButtonShowcase();
Or use MultiPreview to reduce duplication (see doc: custom MultiPreview subclasses).
theme: PreviewThemeData via Preview (or custom annotation extending Preview).wrapper: Wrap the preview to inject InheritedWidgets or MaterialApp-like shells.textScaleFactor, localizations: Match accessibility / locale scenarios.Previews run in an environment built for Flutter Web constraints:
| Topic | Rule |
|---|---|
| dart:io | Avoid in previewed code paths; if transitively imported, APIs throw when called. |
| dart:ffi | Widgets depending on FFI may fail to load entirely. |
| Plugins | Native plugins not supported; web plugins may work in Chrome but are not guaranteed in all environments. |
| Preview annotation callbacks | wrapper / similar parameters must use public names and be compatible with the previewer’s codegen (follow current doc). |
| Assets | Use package paths for dart:ui fromAsset-style loading, e.g. packages/<package>/<asset>. |
Structure conditional imports if platform code must coexist with previews (Dart conditional imports).
session_insight_kit)@Preview entry points under lib/ (e.g. lib/src/presentation/previews/…) so the previewer discovers them.Widget …() (or eligible constructor) with @Preview(name: …, group: …) and optional size / brightness.flutter widget-preview start (or use the IDE preview tab) and confirm light/dark if relevant.dart:io, FFI, or native plugins in the transitive import graph and split stub UI.emulator.getEmulators / Flutter daemon timeout (e.g. 20000ms)If the log shows:
Request "emulator.getEmulators" to daemon was not responded to within 20000ms
this is a Flutter daemon ↔ editor issue, not proof that @Preview code is wrong. The Dart & Flutter extension asks the daemon for the Android emulator list; if that call stalls (slow/hung Android SDK tools, first-run locks on flutter, or daemon load), the same daemon also backs Widget Preview in the IDE, so the preview panel can fail even though previews compile.
Mitigations (try in order):
CLI preview (bypasses the IDE panel) — from the package/app root:
flutter widget-preview start
Opens the preview environment in Chrome; use this when the sidebar preview is broken.
Restart Flutter tooling in the editor — e.g. Dart: Restart Analysis Server, Restart Extension Host, or reload the window; or use the prompt’s Restart Extension if shown.
Diagnose Android / emulator tools — ensure flutter doctor is clean; if emulator or sdkmanager hangs on your machine, fix PATH / Android SDK (stalled emulator enumeration can contribute to daemon backlog).
Separate daemon log (VS Code / compatible editors) — set dart.flutterDaemonLogFile to a path and restart; when the timeout happens, capture FlutterDaemon lines and see Dart-Code #5793.
Note: flutter create --platforms=web is not supported for the package template; rely on flutter widget-preview start and IDE support for packages as documented in current Flutter releases.
Then investigate web-only limits (see Restrictions above) and transitive imports of dart:io / FFI / native plugins.
Preview classMultiPreview for shared preview listsSource: blendfactory/session-insight-kit — distributed by TomeVault.