Line data Source code
1 : /// The database always gives back an `_InternalLinkedHasMap<dynamic, dynamic>`.
2 : /// This creates a deep copy of the json and makes sure that the format is
3 : /// always `Map<String, Object?>`.
4 36 : Map<String, Object?> copyMap(Map map) {
5 36 : final copy = Map<String, dynamic>.from(map);
6 72 : for (final entry in copy.entries) {
7 144 : copy[entry.key] = _castValue(entry.value);
8 : }
9 : return copy;
10 : }
11 :
12 36 : dynamic _castValue(dynamic value) {
13 36 : if (value is Map) {
14 36 : return copyMap(value);
15 : }
16 36 : if (value is List) {
17 28 : return value.map(_castValue).toList();
18 : }
19 : return value;
20 : }
|