fix: Cast instead of shallow copy

This commit is contained in:
Christian Pauly 2021-01-08 12:55:16 +01:00
parent 5ea63b1f1f
commit 0ccf300777
1 changed files with 2 additions and 2 deletions

View File

@ -29,7 +29,7 @@ extension TryGetMapExtension on Map<String, dynamic> {
return fallbackValue; return fallbackValue;
} }
try { try {
return List<T>.from(value); return (value as List).cast<T>();
} catch (_) { } catch (_) {
Logs().w( Logs().w(
'Unable to create "List<${T.runtimeType}>" in event content for the key "$key"'); 'Unable to create "List<${T.runtimeType}>" in event content for the key "$key"');
@ -50,7 +50,7 @@ extension TryGetMapExtension on Map<String, dynamic> {
return fallbackValue; return fallbackValue;
} }
try { try {
return Map<A, B>.from(value); return (value as Map).cast<A, B>();
} catch (_) { } catch (_) {
Logs().w( Logs().w(
'Unable to create "Map<${A.runtimeType},${B.runtimeType}>" in event content for the key "$key"'); 'Unable to create "Map<${A.runtimeType},${B.runtimeType}>" in event content for the key "$key"');