mta-mcp 2.17.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/flutter.agent.md +23 -64
- package/agents/mta.agent.md +226 -0
- package/agents/vue3.agent.md +24 -0
- package/agents/wechat-miniprogram.agent.md +23 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -4
- package/standards/mcp-tools/sketch-mcp.md +497 -0
- package/standards/patterns/design-system-restoration.md +570 -0
- package/standards/syntax-mapping.md +256 -0
- package/standards/workflows/design-restoration.md +401 -0
- package/templates/README.md +14 -0
- package/templates/design-measurement/README.md +81 -0
- package/templates/design-measurement/component-measurement.js +52 -0
- package/templates/design-measurement/gap-measurement.js +79 -0
- package/templates/design-measurement/style-extraction.js +109 -0
- package/common/i18n.md +0 -385
- package/common/typescript-strict.md +0 -186
- package/troubleshooting/README.md +0 -368
- package/troubleshooting/USAGE_GUIDE.md +0 -289
- package/troubleshooting/flutter/clip-/351/230/264/345/275/261/350/243/201/345/211/252.md +0 -244
- package/troubleshooting/flutter/input-/345/255/227/346/256/265/347/274/272/345/244/261.md +0 -240
- package/troubleshooting/flutter/input-/350/276/271/346/241/206/351/227/256/351/242/230.md +0 -236
- package/troubleshooting/flutter/layout-/345/260/272/345/257/270/344/270/215/345/214/271/351/205/215.md +0 -214
- package/troubleshooting/flutter/shadow-/351/200/217/345/207/272/351/227/256/351/242/230.md +0 -172
- package/troubleshooting/flutter/sketch-/345/210/227/350/241/250item/345/214/272/345/237/237.md +0 -212
- package/troubleshooting/flutter/sketch-/345/233/276/346/240/207/345/260/272/345/257/270.md +0 -135
- package/troubleshooting/flutter/sketch-/345/256/214/346/225/264/346/217/220/345/217/226.md +0 -201
- package/troubleshooting/flutter/sketch-/345/261/236/346/200/247/346/234/252/344/275/277/347/224/250.md +0 -139
- package/troubleshooting/flutter/sketch-/350/203/214/346/231/257/345/261/202/351/253/230/345/272/246.md +0 -264
- package/troubleshooting/flutter/svg-/346/234/252/345/261/205/344/270/255.md +0 -120
- package/troubleshooting/flutter/svg-/351/242/234/350/211/262/345/274/202/345/270/270.md +0 -117
- package/troubleshooting/flutter/tabbar-/345/212/250/347/224/273/345/220/214/346/255/245.md +0 -107
- package/troubleshooting/flutter/withopacity-/345/274/203/347/224/250.md +0 -81
- package/troubleshooting/vue3/cascader-/350/257/257/346/233/277/346/215/242.md +0 -130
- package/troubleshooting/vue3/drawer-input-/346/240/267/345/274/217.md +0 -181
- package/troubleshooting/vue3/table-/347/274/226/350/276/221/345/217/226/346/266/210.md +0 -148
- package/troubleshooting/vue3/table-/350/276/271/346/241/206/351/227/256/351/242/230.md +0 -178
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
# 故障排除案例库使用指南
|
|
2
|
-
|
|
3
|
-
> v2.13.0 新增功能 - 让 Copilot 从你的经验中学习
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 🎯 核心价值
|
|
8
|
-
|
|
9
|
-
### 问题场景
|
|
10
|
-
|
|
11
|
-
你正在还原 UI 设计稿,遇到阴影透出问题:
|
|
12
|
-
|
|
13
|
-
**传统流程**(需要 8-10 轮对话):
|
|
14
|
-
```
|
|
15
|
-
你: 阴影不对
|
|
16
|
-
Copilot: 试试降低透明度?
|
|
17
|
-
你: 没用
|
|
18
|
-
Copilot: 改改阴影颜色?
|
|
19
|
-
你: 还是不对
|
|
20
|
-
Copilot: 调整 blurRadius?
|
|
21
|
-
你: 治标不治本
|
|
22
|
-
...(反复多轮)
|
|
23
|
-
最后: 使用 CustomPainter 绘制空心阴影
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**使用案例库**(1 轮解决):
|
|
27
|
-
```
|
|
28
|
-
你: Flutter 新拟态阴影透出问题
|
|
29
|
-
Copilot: [查询案例库] 找到匹配案例 "shadow-透出问题"
|
|
30
|
-
根因:BoxShadow 绘制在容器下方,半透明背景导致阴影透出
|
|
31
|
-
方案:使用 HollowShadowPainter
|
|
32
|
-
[直接提供完整代码]
|
|
33
|
-
你: 完美!
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
**节省**: 7-9 轮对话,约 10-15 分钟
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## 🚀 快速开始
|
|
41
|
-
|
|
42
|
-
### 1. 更新 MCP 服务器
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
cd /Users/pailasi/Work/copilot-prompts/mcp-server
|
|
46
|
-
npm run build
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### 2. 在 Copilot Chat 中使用
|
|
50
|
-
|
|
51
|
-
#### 场景 A:遇到具体问题
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
@copilot 我的 Flutter 新拟态容器背景比设计稿暗,阴影好像透出来了
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Copilot 会自动:
|
|
58
|
-
1. 识别关键词:`flutter`, `新拟态`, `阴影透出`
|
|
59
|
-
2. 调用 `query_troubleshooting_cases`
|
|
60
|
-
3. 返回最相关的案例和解决方案
|
|
61
|
-
|
|
62
|
-
#### 场景 B:主动查询
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
@copilot 查询 Vue3 表格边框相关的故障排除案例
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
#### 场景 C:列出所有案例
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
@copilot 列出所有 Flutter 故障排除案例
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## 🧪 MCP 工具使用
|
|
77
|
-
|
|
78
|
-
### query_troubleshooting_cases
|
|
79
|
-
|
|
80
|
-
**参数**:
|
|
81
|
-
```typescript
|
|
82
|
-
{
|
|
83
|
-
framework?: "flutter" | "vue3" | "react" | "common",
|
|
84
|
-
keywords?: string[], // 问题关键词
|
|
85
|
-
errorMessage?: string, // 错误信息
|
|
86
|
-
codePattern?: string, // 问题代码片段
|
|
87
|
-
limit?: number // 最多返回案例数(默认5)
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**返回**:
|
|
92
|
-
```typescript
|
|
93
|
-
{
|
|
94
|
-
cases: [
|
|
95
|
-
{
|
|
96
|
-
id: "shadow-透出问题",
|
|
97
|
-
title: "Flutter 阴影透出问题",
|
|
98
|
-
framework: "flutter",
|
|
99
|
-
tags: ["shadow", "neumorphism", "transparency"],
|
|
100
|
-
matchScore: 85, // 匹配度 0-100
|
|
101
|
-
timeSaved: "6-10轮对话",
|
|
102
|
-
preview: "问题根源:BoxShadow 绘制在容器下方..."
|
|
103
|
-
}
|
|
104
|
-
],
|
|
105
|
-
totalFound: 3,
|
|
106
|
-
queryInfo: { framework: "flutter", keywords: ["shadow"] }
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### get_troubleshooting_case
|
|
111
|
-
|
|
112
|
-
**获取案例完整内容**:
|
|
113
|
-
```typescript
|
|
114
|
-
{
|
|
115
|
-
framework: "flutter",
|
|
116
|
-
caseId: "shadow-透出问题"
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
**返回**:
|
|
121
|
-
```typescript
|
|
122
|
-
{
|
|
123
|
-
content: "# Flutter 阴影透出问题\n\n...", // 完整 Markdown
|
|
124
|
-
metadata: { ... }
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
## 📝 贡献案例
|
|
131
|
-
|
|
132
|
-
### 何时创建案例?
|
|
133
|
-
|
|
134
|
-
- ✅ 问题需要 **3 轮以上对话**才解决
|
|
135
|
-
- ✅ 错误路线明确(知道哪些方案无效)
|
|
136
|
-
- ✅ 有明确的**正确方案**
|
|
137
|
-
- ✅ 问题有**通用性**(其他项目可能遇到)
|
|
138
|
-
|
|
139
|
-
### 案例模板
|
|
140
|
-
|
|
141
|
-
在 `troubleshooting/{framework}/` 下创建 Markdown 文件:
|
|
142
|
-
|
|
143
|
-
```markdown
|
|
144
|
-
# 问题标题
|
|
145
|
-
|
|
146
|
-
> **问题标签**: `tag1`, `tag2`, `tag3`
|
|
147
|
-
> **问题类型**: 分类名称
|
|
148
|
-
> **框架**: Flutter/Vue3/React
|
|
149
|
-
> **严重程度**: 低/中/高
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## 🔍 问题识别
|
|
154
|
-
|
|
155
|
-
### 自动检测特征
|
|
156
|
-
- 代码模式:\`\`\`dart ... \`\`\`
|
|
157
|
-
- 错误信息关键词
|
|
158
|
-
|
|
159
|
-
### 用户描述关键词
|
|
160
|
-
- "xxx不对"
|
|
161
|
-
- "xxx比设计稿暗"
|
|
162
|
-
|
|
163
|
-
### 问题特征 Checklist
|
|
164
|
-
- [ ] 特征1
|
|
165
|
-
- [ ] 特征2
|
|
166
|
-
|
|
167
|
-
---
|
|
168
|
-
|
|
169
|
-
## ❌ 常见错误排查路线(避免重复)
|
|
170
|
-
|
|
171
|
-
| 尝试方向 | 为什么无效 | 浪费时间 |
|
|
172
|
-
|----------|-----------|---------|
|
|
173
|
-
| 方案A | 原因 | 2轮 |
|
|
174
|
-
| 方案B | 原因 | 3轮 |
|
|
175
|
-
|
|
176
|
-
**总计浪费**: X 轮对话
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
## ✅ 正确解决方案
|
|
181
|
-
|
|
182
|
-
### 核心原理
|
|
183
|
-
解释问题根因...
|
|
184
|
-
|
|
185
|
-
### 解决方法
|
|
186
|
-
\`\`\`dart
|
|
187
|
-
// 完整代码
|
|
188
|
-
\`\`\`
|
|
189
|
-
|
|
190
|
-
### 使用示例
|
|
191
|
-
\`\`\`dart
|
|
192
|
-
// 实际应用
|
|
193
|
-
\`\`\`
|
|
194
|
-
|
|
195
|
-
---
|
|
196
|
-
|
|
197
|
-
## 📋 适用场景
|
|
198
|
-
- ✅ 场景1
|
|
199
|
-
- ✅ 场景2
|
|
200
|
-
|
|
201
|
-
## 🔗 相关案例
|
|
202
|
-
- [相关案例1](./xxx.md)
|
|
203
|
-
|
|
204
|
-
---
|
|
205
|
-
|
|
206
|
-
**来源**: 项目名
|
|
207
|
-
**创建日期**: YYYY-MM-DD
|
|
208
|
-
**节省时间**: X-Y 轮对话
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
---
|
|
212
|
-
|
|
213
|
-
## 🤖 Agent 集成
|
|
214
|
-
|
|
215
|
-
最新的 Agent 配置已自动包含案例库查询:
|
|
216
|
-
|
|
217
|
-
### Flutter Agent
|
|
218
|
-
|
|
219
|
-
```markdown
|
|
220
|
-
## ⚠️ 强制工作流
|
|
221
|
-
|
|
222
|
-
### 步骤 0: 遇到问题时优先查询案例库 🆘
|
|
223
|
-
|
|
224
|
-
**如果遇到以下情况,立即查询故障排除案例:**
|
|
225
|
-
- 编译错误或运行时错误
|
|
226
|
-
- UI 还原与设计稿不符
|
|
227
|
-
- 需要多轮对话才能解决的问题
|
|
228
|
-
|
|
229
|
-
\`\`\`
|
|
230
|
-
query_troubleshooting_cases({
|
|
231
|
-
framework: "flutter",
|
|
232
|
-
keywords: ["问题关键词"],
|
|
233
|
-
errorMessage: "错误描述"
|
|
234
|
-
})
|
|
235
|
-
\`\`\`
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Vue3 Agent
|
|
239
|
-
|
|
240
|
-
```markdown
|
|
241
|
-
### 步骤 0: 遇到问题时优先查询案例库 🆘
|
|
242
|
-
|
|
243
|
-
**常见问题关键词**:
|
|
244
|
-
- `table`, `border` - 表格边框问题
|
|
245
|
-
- `i18n`, `hardcode` - 国际化硬编码
|
|
246
|
-
- `css`, `style` - 样式冲突
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
## 📊 效果统计
|
|
252
|
-
|
|
253
|
-
基于 my_flutter 项目实测:
|
|
254
|
-
|
|
255
|
-
| 问题类型 | 传统耗时 | 使用案例库 | 节省 |
|
|
256
|
-
|---------|---------|-----------|------|
|
|
257
|
-
| 新拟态阴影透出 | 10轮 | 1轮 | 90% |
|
|
258
|
-
| 输入框布局不匹配 | 6轮 | 1-2轮 | 70% |
|
|
259
|
-
| 组件字段缺失 | 3轮 | 1轮 | 66% |
|
|
260
|
-
|
|
261
|
-
**平均节省**: 4-8 轮对话/问题
|
|
262
|
-
|
|
263
|
-
---
|
|
264
|
-
|
|
265
|
-
## 🔮 路线图
|
|
266
|
-
|
|
267
|
-
### v2.13.0 ✅
|
|
268
|
-
- [x] 基础案例库结构
|
|
269
|
-
- [x] MCP 工具实现
|
|
270
|
-
- [x] Agent 集成
|
|
271
|
-
- [x] Flutter 首个案例
|
|
272
|
-
- [x] Vue3 首个案例
|
|
273
|
-
|
|
274
|
-
### v2.14.0(规划中)
|
|
275
|
-
- [ ] 自动问题检测(基于错误信息)
|
|
276
|
-
- [ ] 代码模式匹配
|
|
277
|
-
- [ ] 更多框架支持(React, Angular)
|
|
278
|
-
- [ ] 案例贡献工作流
|
|
279
|
-
|
|
280
|
-
### v2.15.0(规划中)
|
|
281
|
-
- [ ] AI 辅助案例生成
|
|
282
|
-
- [ ] 相似问题推荐
|
|
283
|
-
- [ ] 案例有效性反馈机制
|
|
284
|
-
|
|
285
|
-
---
|
|
286
|
-
|
|
287
|
-
**维护者**: MTA工作室
|
|
288
|
-
**创建日期**: 2026-01-16
|
|
289
|
-
**版本**: v2.13.0
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
# Flutter clipBehavior 阴影裁剪问题
|
|
2
|
-
|
|
3
|
-
> **问题标签**: `clip`, `shadow`, `layout`, `overflow`, `neumorphism`
|
|
4
|
-
> **问题类型**: 布局裁剪
|
|
5
|
-
> **框架**: Flutter
|
|
6
|
-
> **严重程度**: 中等(视觉问题)
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## 🔍 问题识别
|
|
11
|
-
|
|
12
|
-
### 自动检测特征
|
|
13
|
-
|
|
14
|
-
```dart
|
|
15
|
-
// 代码模式匹配 - 嵌套容器带阴影
|
|
16
|
-
Container(
|
|
17
|
-
// 外层容器有 padding
|
|
18
|
-
padding: EdgeInsets.all(6),
|
|
19
|
-
child: Container(
|
|
20
|
-
decoration: BoxDecoration(
|
|
21
|
-
boxShadow: [...], // 内层有阴影
|
|
22
|
-
),
|
|
23
|
-
),
|
|
24
|
-
)
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### 用户描述关键词
|
|
28
|
-
- "阴影模糊一片"
|
|
29
|
-
- "阴影没有清晰边界"
|
|
30
|
-
- "阴影被裁剪了"
|
|
31
|
-
- "新拟态效果不清晰"
|
|
32
|
-
- "选中项看不出凸起效果"
|
|
33
|
-
|
|
34
|
-
### 问题特征
|
|
35
|
-
- [ ] 新拟态选中项阴影看起来"模糊一片"
|
|
36
|
-
- [ ] 阴影没有清晰的边界
|
|
37
|
-
- [ ] 选中项与背景融为一体
|
|
38
|
-
- [ ] 类似效果的其他组件显示正常
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## ❌ 常见错误排查路线(避免重复)
|
|
43
|
-
|
|
44
|
-
| 尝试方向 | 为什么无效 | 浪费时间 |
|
|
45
|
-
|----------|-----------|---------|
|
|
46
|
-
| 调整阴影参数 (blur/offset) | 问题不在阴影本身 | 2-3 轮对话 |
|
|
47
|
-
| 嵌套两层 Container (外层阴影/内层渐变) | 阴影仍在裁剪区域内 | 2-3 轮对话 |
|
|
48
|
-
| 添加白色边框产生锐利边缘 | 边框过于明显,产生分层感 | 1-2 轮对话 |
|
|
49
|
-
| 使用叠加渐变模拟内阴影 | 效果不自然 | 1-2 轮对话 |
|
|
50
|
-
| 只设置 Stack 的 clipBehavior | 外层 Container 仍会裁剪 | 1 轮对话 |
|
|
51
|
-
|
|
52
|
-
**总计浪费**: 7-11 轮对话
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## ✅ 正确解决方案
|
|
57
|
-
|
|
58
|
-
### 核心原理
|
|
59
|
-
|
|
60
|
-
**问题根源**:Flutter 的 `Container`、`Padding`、`ClipRRect` 等组件**默认会裁剪**超出边界的内容,包括 `BoxShadow` 阴影。
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
问题结构:
|
|
64
|
-
Container (默认 clipBehavior: Clip.hardEdge)
|
|
65
|
-
└── Padding (padding: 6)
|
|
66
|
-
└── Container
|
|
67
|
-
└── 带阴影的滑块 ← 阴影被最外层 Container 裁剪!
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### 解决步骤
|
|
71
|
-
|
|
72
|
-
#### 1. 设置 clipBehavior: Clip.none
|
|
73
|
-
|
|
74
|
-
```dart
|
|
75
|
-
Container(
|
|
76
|
-
clipBehavior: Clip.none, // ← 关键!允许内容溢出
|
|
77
|
-
decoration: BoxDecoration(
|
|
78
|
-
color: config.backgroundColor,
|
|
79
|
-
borderRadius: BorderRadius.circular(config.borderRadius),
|
|
80
|
-
),
|
|
81
|
-
child: Stack(
|
|
82
|
-
clipBehavior: Clip.none, // ← Stack 也要设置
|
|
83
|
-
children: [
|
|
84
|
-
// ...
|
|
85
|
-
],
|
|
86
|
-
),
|
|
87
|
-
)
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
#### 2. 重构布局结构
|
|
91
|
-
|
|
92
|
-
**错误的结构**(会裁剪):
|
|
93
|
-
```dart
|
|
94
|
-
Container(
|
|
95
|
-
padding: EdgeInsets.all(6), // padding 会导致裁剪
|
|
96
|
-
child: Stack(
|
|
97
|
-
children: [
|
|
98
|
-
Container(boxShadow: [...]), // 阴影被外层裁剪
|
|
99
|
-
],
|
|
100
|
-
),
|
|
101
|
-
)
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
**正确的结构**(不裁剪):
|
|
105
|
-
```dart
|
|
106
|
-
Container(
|
|
107
|
-
clipBehavior: Clip.none,
|
|
108
|
-
child: Stack(
|
|
109
|
-
clipBehavior: Clip.none,
|
|
110
|
-
children: [
|
|
111
|
-
Positioned( // 使用 Positioned 代替 padding
|
|
112
|
-
left: 6,
|
|
113
|
-
top: 6,
|
|
114
|
-
bottom: 6,
|
|
115
|
-
right: 6,
|
|
116
|
-
child: Container(boxShadow: [...]),
|
|
117
|
-
),
|
|
118
|
-
],
|
|
119
|
-
),
|
|
120
|
-
)
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
#### 3. 完整示例
|
|
124
|
-
|
|
125
|
-
```dart
|
|
126
|
-
@override
|
|
127
|
-
Widget build(BuildContext context) {
|
|
128
|
-
final config = _getConfig();
|
|
129
|
-
final selectedIndex = items.indexWhere((item) => item.value == selectedValue);
|
|
130
|
-
final innerPadding = padding ?? const EdgeInsets.all(6);
|
|
131
|
-
|
|
132
|
-
return LayoutBuilder(
|
|
133
|
-
builder: (context, outerConstraints) {
|
|
134
|
-
final totalWidth = outerConstraints.maxWidth;
|
|
135
|
-
final innerWidth = totalWidth - innerPadding.horizontal;
|
|
136
|
-
final itemWidth = innerWidth / items.length;
|
|
137
|
-
|
|
138
|
-
return Container(
|
|
139
|
-
height: height,
|
|
140
|
-
clipBehavior: Clip.none, // 关键点1:允许溢出
|
|
141
|
-
decoration: BoxDecoration(
|
|
142
|
-
color: config.backgroundColor,
|
|
143
|
-
borderRadius: BorderRadius.circular(config.borderRadius),
|
|
144
|
-
boxShadow: config.shadow,
|
|
145
|
-
),
|
|
146
|
-
child: Stack(
|
|
147
|
-
clipBehavior: Clip.none, // 关键点2:Stack 也允许溢出
|
|
148
|
-
children: [
|
|
149
|
-
// 滑动背景 - 使用 Positioned 精确定位
|
|
150
|
-
if (selectedIndex != -1)
|
|
151
|
-
Positioned(
|
|
152
|
-
left: innerPadding.left + (itemWidth * selectedIndex),
|
|
153
|
-
top: innerPadding.top,
|
|
154
|
-
bottom: innerPadding.bottom,
|
|
155
|
-
width: itemWidth,
|
|
156
|
-
child: AnimatedContainer(
|
|
157
|
-
duration: $d.fast,
|
|
158
|
-
curve: Curves.easeInOut,
|
|
159
|
-
decoration: BoxDecoration(
|
|
160
|
-
gradient: config.selectedGradient,
|
|
161
|
-
borderRadius: BorderRadius.circular(12),
|
|
162
|
-
boxShadow: config.selectedShadow, // 阴影在这里
|
|
163
|
-
),
|
|
164
|
-
),
|
|
165
|
-
),
|
|
166
|
-
|
|
167
|
-
// 文本层 - 使用 Padding 而非容器的 padding
|
|
168
|
-
Padding(
|
|
169
|
-
padding: innerPadding,
|
|
170
|
-
child: Row(
|
|
171
|
-
children: items.map((item) {
|
|
172
|
-
return Expanded(
|
|
173
|
-
child: GestureDetector(
|
|
174
|
-
onTap: () => onChanged(item.value),
|
|
175
|
-
child: Container(
|
|
176
|
-
alignment: Alignment.center,
|
|
177
|
-
child: Text(item.label, ...),
|
|
178
|
-
),
|
|
179
|
-
),
|
|
180
|
-
);
|
|
181
|
-
}).toList(),
|
|
182
|
-
),
|
|
183
|
-
),
|
|
184
|
-
],
|
|
185
|
-
),
|
|
186
|
-
);
|
|
187
|
-
},
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## 📋 关键改动点
|
|
195
|
-
|
|
196
|
-
### 1. clipBehavior 设置
|
|
197
|
-
- ✅ Container: `clipBehavior: Clip.none`
|
|
198
|
-
- ✅ Stack: `clipBehavior: Clip.none`
|
|
199
|
-
- ✅ 所有可能裁剪的父组件都要设置
|
|
200
|
-
|
|
201
|
-
### 2. 布局方式
|
|
202
|
-
- ❌ Container 的 padding 属性
|
|
203
|
-
- ✅ Positioned 精确定位
|
|
204
|
-
- ✅ Padding widget 包裹内容
|
|
205
|
-
|
|
206
|
-
### 3. 使用 LayoutBuilder
|
|
207
|
-
提前计算尺寸,避免布局错误:
|
|
208
|
-
```dart
|
|
209
|
-
LayoutBuilder(
|
|
210
|
-
builder: (context, constraints) {
|
|
211
|
-
final totalWidth = constraints.maxWidth;
|
|
212
|
-
final innerWidth = totalWidth - padding.horizontal;
|
|
213
|
-
final itemWidth = innerWidth / items.length;
|
|
214
|
-
// ...
|
|
215
|
-
},
|
|
216
|
-
)
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
---
|
|
220
|
-
|
|
221
|
-
## 💡 clipBehavior 值说明
|
|
222
|
-
|
|
223
|
-
| 值 | 行为 | 性能 | 使用场景 |
|
|
224
|
-
|----|------|------|---------|
|
|
225
|
-
| `Clip.none` | 不裁剪,允许溢出 | 最好 | **需要显示阴影** |
|
|
226
|
-
| `Clip.hardEdge` | 硬边裁剪(默认) | 好 | 一般容器 |
|
|
227
|
-
| `Clip.antiAlias` | 抗锯齿裁剪 | 中 | 圆角需要平滑 |
|
|
228
|
-
| `Clip.antiAliasWithSaveLayer` | 最高质量裁剪 | 差 | 尽量避免 |
|
|
229
|
-
|
|
230
|
-
**推荐**:需要阴影时使用 `Clip.none`,其他情况保持默认。
|
|
231
|
-
|
|
232
|
-
---
|
|
233
|
-
|
|
234
|
-
## 🔗 相关案例
|
|
235
|
-
|
|
236
|
-
- [shadow-透出问题](./shadow-透出问题.md) - 另一个阴影相关问题
|
|
237
|
-
- [layout-尺寸不匹配](./layout-尺寸不匹配.md) - 使用 Positioned 精确布局
|
|
238
|
-
|
|
239
|
-
---
|
|
240
|
-
|
|
241
|
-
**来源**: my_flutter 项目实战经验
|
|
242
|
-
**创建日期**: 2025-12-31
|
|
243
|
-
**最后验证**: 2026-01-16
|
|
244
|
-
**节省时间**: 7-11 轮对话
|