# PlatformException: error: 1, message: Invalid argument, details: Expected a Map but got List

- **ID:** `flutter/platform-channel-argument-error`
- **Domain:** flutter
- **Category:** protocol_error
- **Error Code:** `1`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Platform channel method call arguments are not a valid Map, often due to incorrect encoding on the native side.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Flutter 3.22.0 | active | — | — |
| Dart 3.4.0 | active | — | — |
| Kotlin 1.9.22 | active | — | — |
| Swift 5.9 | active | — | — |

## Workarounds

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(...))`.** (90% success)
   ```
   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.** (85% success)
   ```
   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}"); }`.** (75% success)
   ```
   Add a try-catch on the native side to log the exact argument type: `try { ... } catch (e) { Log.e("Channel", "Argument type: ${arg.runtimeType}"); }`.
   ```

## Dead Ends

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