Dart 模式匹配
原名:dart-use-pattern-matching
在合适位置使用 switch 表达式、解构和模式匹配简化 Dart 代码。
中文 Skills 技能说明
适合分支判断复杂、数据结构清晰且项目 Dart 版本支持的代码。技能会先确认语义等价和可读性,再做小范围重构;不要为了追新语法改动稳定代码,完成后应运行静态分析和相关测试。
上游能力依据
上游原始适用说明:Use switch expressions and pattern matching where appropriate
上游 SKILL.md 主要章节(保留原文标题):
- Contents
- Pattern Selection Strategy
- Switch Statements vs. Expressions
- Core Pattern Implementations
- Workflows
- Task Progress: Implementing Pattern Matching
- Feedback Loop: Exhaustiveness Checking
- Examples
- JSON Validation and Destructuring
- Algebraic Data Types (Sealed Classes)
使用边界
先读取项目约定、依赖版本和现有测试,再提出最小改动。写文件、运行脚本、提交代码或发布前应检查差异并保留回退路径。
作者、翻译与许可证
- 原作者
- The Flutter Authors 与 flutter/agent-plugins contributors
- 中文翻译
- CEOFans翻译
- 许可证
- BSD-3-Clause
- 上游来源
- https://github.com/flutter/agent-plugins/tree/864cf8797b190ddb81e4875db6dd6bab89641f62/skills/dart-use-pattern-matching
适用范围
平台:linux、macos、windows;标签:软件开发、Dart 模式匹配
安全提示
基础静态扫描不等于绝对安全。技能可能调用命令、浏览器、云服务或本地文件,请在最小权限环境中使用,高风险操作必须人工确认。
如发现侵权、许可证或安全问题,可在本页前台提交投诉,管理员复核后可立即下架。