validateNoExtraListItems function
Validates that there are no extra list items beyond the expected count.
@param cursor The line cursor @param itemDepth The expected depth of items @param expectedCount The expected number of items @throws RangeError if extra items are found
Implementation
void validateNoExtraListItems(
LineCursor cursor, int itemDepth, int expectedCount) {
if (cursor.atEnd()) {
return;
}
final nextLine = cursor.peek();
if (nextLine != null &&
nextLine.depth == itemDepth &&
nextLine.content.startsWith(listItemPrefix)) {
throw RangeError(
'Expected $expectedCount list array items, but found more');
}
}