plugins/languages/flutter/skills/web/SKILL.md
Flutter Web 规范 — WASM (dart2wasm) 编译、CanvasKit/HTML 渲染选型、响应式 Web 布局、PWA (manifest + service worker)、SEO/Semantics、usePathUrlStrategy。当用户开发 Flutter Web、提到 "Web"、"WASM"、"CanvasKit"、"PWA"、"SEO"、"浏览器" 时加载。
npx skillsauth add lazygophers/ccplugin flutter-webInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
| 引擎 | 推荐场景 | 优势 | 劣势 |
| --- | --- | --- | --- |
| WASM (dart2wasm) | 高性能应用 (Flutter 3.22+ stable) | 最快执行 / 小包体 | 需现代浏览器 (Chromium/Firefox/Safari 16.4+) |
| CanvasKit | 图形密集 / 像素一致 | 跨浏览器一致、复杂动画稳 | 初次加载 ~2MB |
| HTML renderer | (旧) SEO 优先 / 弱设备 | 小包体、原生 DOM | Flutter 3.27 起标记弃用 |
# WASM (推荐)
flutter build web --wasm
# CanvasKit (兜底)
flutter build web --web-renderer canvaskit
LayoutBuilder(
builder: (_, c) => switch (c.maxWidth) {
< 600 => MobileScaffold(child: child),
< 1200 => TabletScaffold(child: child),
_ => DesktopScaffold(child: child),
},
);
// 最大宽度约束 (避免超宽屏拉伸)
Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 1200),
child: content,
),
);
// 用 sizeOf 减少重建
final w = MediaQuery.sizeOf(context).width;
import 'package:flutter_web_plugins/url_strategy.dart';
void main() {
usePathUrlStrategy(); // 路径式 URL (非 #hash)
runApp(const MyApp());
}
// 推迟加载非首屏代码
import 'package:my_app/admin.dart' deferred as admin;
Future<void> openAdmin(BuildContext ctx) async {
await admin.loadLibrary();
Navigator.of(ctx).push(MaterialPageRoute(builder: (_) => admin.AdminPage()));
}
go_router 配置中按路由切分 deferred import 可显著减小首屏 Bundle。
// web/manifest.json
{
"name": "My Flutter App",
"short_name": "MyApp",
"start_url": ".",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#2196F3",
"icons": [
{"src": "icons/Icon-192.png", "sizes": "192x192", "type": "image/png"},
{"src": "icons/Icon-512.png", "sizes": "512x512", "type": "image/png"}
]
}
Service worker flutter_service_worker.js Flutter 默认生成;离线数据用 shared_preferences / hive。
// 语义化
Semantics(label: 'User profile card', child: const UserCard());
// 页面元数据 — web/index.html 配 <meta name="description">
// 动态标题 (TitleNotifier 包 SystemChrome)
CanvasKit/WASM 文本对搜索引擎不可见;SEO 关键页面考虑 SSR/SSG (e.g. jaspr) 或独立 HTML landing。
Image.network(
url,
cacheWidth: 800,
cacheHeight: 600,
loadingBuilder: (ctx, child, p) => p == null ? child : const CircularProgressIndicator(),
);
import 'package:flutter/foundation.dart';
if (kIsWeb) {
// Web 特定
}
// 条件导入处理 dart:html / dart:io
import 'stub.dart'
if (dart.library.js_interop) 'web.dart'
if (dart.library.io) 'native.dart';
| AI 借口 | 实际检查 | 严重度 |
| --- | --- | --- |
| "CanvasKit 就行" | 是否考虑 WASM? | 中 |
| "FCP 不重要" | FCP < 2s? | 高 |
| "不需要响应式" | 手机/平板/桌面三断点是否覆盖? | 高 |
| "hash URL 也行" | 是否 usePathUrlStrategy()? | 中 |
| "图片直接加载" | cacheWidth/cacheHeight 降采样? | 中 |
| "一次加载全部" | 是否 deferred import 拆包? | 中 |
| "SEO 不重要" | Semantics + meta 是否补全? | 中 |
flutter build web --wasm)MediaQuery.sizeOf 降重建ConstrainedBox 限最大宽度usePathUrlStrategy()Semantics 语义化Skills(flutter:core) / Skills(flutter:ui) / Skills(flutter:state)tools
--- name: trellisx-workspace description: 维护 `.trellis/task.md` 任务看板 —— trellis 缺的跨任务总览。**一个表格, 一行一个任务**, 列为 id/名称/描述/状态/阶段/进度/worktree (状态/阶段中文显示)。在 task create/start/阶段切换/archive 后**及时更新**对应行; 并**自动清理超 7 天的已完成行**防膨胀。保持看板与 task.json 实时一致。 when_to_use: 维护 / 创建 / 更新 `.trellis/task.md` 任务看板时; task 生命周期任一节点 (create/start/阶段推进/archive) 之后同步看板时; 用户问"当前有哪些任务 / 任务进度 / 任务看板"时。被 trellisx-flow 与 trellisx-apply 注入的流程引用。 user-invocable: true argument-hint: [show|update|sync|cleanup ...] [task id] arguments:
testing
强制以 Trellis task 闭环处理用户指定的请求 (自判新建/并入 → plan→exec→check→finish 全程不跳步)。**仅用户显式主动调用** (/trellisx-flow 或明确要求"强制走 task 处理这个"); **禁止自动 / 被动 / 推断式调用** —— 不要因为某个请求"看起来该建 task"就自动触发本 skill, 那是 apply 注入的 no_task 倾向的职责。
testing
把 强推task + subtask拆分 + worktree隔离 + 闭环收尾 四维度增量注入当前项目 .trellis/ (workflow.md 的 no_task/planning/in_progress 块 + spec 背书文档 + trellis 生命周期 hook worktree 自动化)。强推 task 与闭环为纯 prompt 软约束 (非平台 hook 硬拦截)。**纯增量追加, 绝不替换 trellis 原生文本** (no_task 分类+征同意/check/finish/前缀全保留)。幂等 (marker 包裹)。
development
Claude Code 会话历史整理 — 扫 ~/.claude/projects/**/*.jsonl 全部 session transcripts, 提取学习增量 (用户校正/决策/踩坑/L0 规则) → 全局记忆库 ~/.cortex/.wiki/memory/. 默认 --apply 落盘 (--dry-run opt-in 仅出 JSON plan 预览). 与 cortex-extract (L4-inbox 内部) 互补.