decodeObjectFromListItem function
Map<String, Object?>
decodeObjectFromListItem(
- ParsedLine firstLine,
- LineCursor cursor,
- int baseDepth,
- ResolvedDecodeOptions options,
Decodes an object from a list item
Implementation
Map<String, Object?> decodeObjectFromListItem(
ParsedLine firstLine,
LineCursor cursor,
int baseDepth,
ResolvedDecodeOptions options,
) {
final afterHyphen = firstLine.content.substring(listItemPrefix.length);
final kv = _decodeKeyValue(afterHyphen, cursor, baseDepth, options);
final obj = <String, Object?>{kv.key: kv.value};
// Read subsequent fields
while (!cursor.atEnd()) {
final line = cursor.peek();
if (line == null || line.depth < kv.followDepth) {
break;
}
if (line.depth == kv.followDepth &&
!line.content.startsWith(listItemPrefix)) {
final (k, v) = decodeKeyValuePair(line, cursor, kv.followDepth, options);
obj[k] = v;
} else {
break;
}
}
return obj;
}