Skip to content

Commit 8df589c

Browse files
CopilotAlexV525
andcommitted
Fix presentLimited type error by casting map to Map<String, dynamic>
Co-authored-by: AlexV525 <[email protected]>
1 parent 1c89174 commit 8df589c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ To know more about breaking changes, see the [Migration Guide][].
88

99
## Unreleased
1010

11-
*None.*
11+
**Fixes**
12+
13+
- Fix type error when calling `presentLimited` due to map type inference issue with `putIfAbsent`.
1214

1315
## 3.8.1
1416

lib/src/internal/plugin.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ class PMMethodChannel extends MethodChannel {
3939
if (arguments is! Map) {
4040
return super.invokeMethod<T>(method, arguments);
4141
}
42-
arguments.putIfAbsent(
42+
// Cast to Map<String, dynamic> to avoid type mismatch when the original map
43+
// has a narrow value type (e.g., Map<String, int>)
44+
final Map<String, dynamic> args = Map<String, dynamic>.from(arguments);
45+
args.putIfAbsent(
4346
PMConstants.cancelTokenKey,
4447
() => PMCancelToken().key,
4548
);
46-
return super.invokeMethod<T>(method, arguments);
49+
return super.invokeMethod<T>(method, args);
4750
}
4851
}
4952

0 commit comments

Comments
 (0)