mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-09-13 06:33:00 +08:00
MdYamlCodec: Load maps properly
Our MdYamlCodec runs inside an isolate, and send the result back. The YamlMap data structure doesn't seem to be serializable over an isolate and gives us an error. Therefore, we should make sure it is a normal map.
This commit is contained in:
@ -91,9 +91,7 @@ class MarkdownYAMLCodec {
|
||||
if (yamlMap is! Map) {
|
||||
return map;
|
||||
}
|
||||
yamlMap.forEach((key, value) {
|
||||
map[key] = value;
|
||||
});
|
||||
map = _convertMap(yamlMap);
|
||||
} catch (err) {
|
||||
Log.d('MarkdownYAMLSerializer::decode("$yamlText") -> ${err.toString()}');
|
||||
}
|
||||
@ -125,3 +123,16 @@ class MarkdownYAMLCodec {
|
||||
return "---\n" + yaml + "---\n";
|
||||
}
|
||||
}
|
||||
|
||||
LinkedHashMap<String, dynamic> _convertMap(YamlMap yamlMap) {
|
||||
LinkedHashMap<String, dynamic> map = LinkedHashMap<String, dynamic>();
|
||||
|
||||
yamlMap.forEach((key, value) {
|
||||
if (value is YamlMap) {
|
||||
value = _convertMap(value);
|
||||
}
|
||||
map[key] = value;
|
||||
});
|
||||
|
||||
return map;
|
||||
}
|
||||
|
Reference in New Issue
Block a user