# PlatformException: 错误: 1, 消息: 无效参数, 详情: 期望 Map 但得到 List

- **ID:** `flutter/platform-channel-argument-error`
- **领域:** flutter
- **类别:** protocol_error
- **错误码:** `1`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

平台通道方法调用参数不是有效的 Map，通常是由于原生端编码错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Flutter 3.22.0 | active | — | — |
| Dart 3.4.0 | active | — | — |
| Kotlin 1.9.22 | active | — | — |
| Swift 5.9 | active | — | — |

## 解决方案

1. ```
   In the native Android handler, ensure arguments are wrapped in a HashMap. Example: `result.success(mapOf("key" to value))` instead of `result.success(listOf(...))`.
   ```
2. ```
   On iOS, use a dictionary: `result(["key": value])` and verify the Flutter side expects a Map. Also check for nil values in the dictionary.
   ```
3. ```
   Add a try-catch on the native side to log the exact argument type: `try { ... } catch (e) { Log.e("Channel", "Argument type: ${arg.runtimeType}"); }`.
   ```

## 无效尝试

- **** — The root cause is in the native method channel implementation, not a transient state issue. (95% 失败率)
- **** — The error is raised on the native side before Dart receives the response; null checks don't fix encoding. (90% 失败率)
- **** — The error is specific to custom method channel code, not package compatibility. (80% 失败率)
