Fix dictionary/map deserialization (#19496)

This commit is contained in:
rankoz 2024-09-16 18:18:04 +03:00 committed by GitHub
parent 1b30c1995f
commit ff1fe256d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View File

@ -52,13 +52,13 @@ final _regMap = RegExp(r'^Map<String,(.*)>$');
.toSet() as ReturnType; .toSet() as ReturnType;
} }
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) { if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
targetType = match![1]!; // ignore: parameter_assignments targetType = match![1]!.trim(); // ignore: parameter_assignments
return Map<dynamic, BaseType>.fromIterables( return Map<String, BaseType>.fromIterables(
value.keys, value.keys as Iterable<String>,
value.values.map((dynamic v) => deserialize<BaseType, BaseType>(v, targetType, growable: growable)), value.values.map((dynamic v) => deserialize<BaseType, BaseType>(v, targetType, growable: growable)),
) as ReturnType; ) as ReturnType;
} }
break; break;
} }
throw Exception('Cannot deserialize'); throw Exception('Cannot deserialize');
} }

View File

@ -183,13 +183,13 @@ final _regMap = RegExp(r'^Map<String,(.*)>$');
.toSet() as ReturnType; .toSet() as ReturnType;
} }
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) { if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
targetType = match![1]!; // ignore: parameter_assignments targetType = match![1]!.trim(); // ignore: parameter_assignments
return Map<dynamic, BaseType>.fromIterables( return Map<String, BaseType>.fromIterables(
value.keys, value.keys as Iterable<String>,
value.values.map((dynamic v) => deserialize<BaseType, BaseType>(v, targetType, growable: growable)), value.values.map((dynamic v) => deserialize<BaseType, BaseType>(v, targetType, growable: growable)),
) as ReturnType; ) as ReturnType;
} }
break; break;
} }
throw Exception('Cannot deserialize'); throw Exception('Cannot deserialize');
} }