removeTrailingEmptyLines method

bool removeTrailingEmptyLines(
  1. List<ListItem> items
)

Removes any trailing empty lines and notes whether any items are separated by such lines.

Implementation

bool removeTrailingEmptyLines(List<ListItem> items) {
  var anyEmpty = false;
  for (var i = 0; i < items.length; i++) {
    if (items[i].lines.length == 1) {
      continue;
    }
    while (items[i].lines.isNotEmpty && _emptyPattern.hasMatch(items[i].lines.last)) {
      if (i < items.length - 1) {
        anyEmpty = true;
      }
      items[i].lines.removeLast();
    }
  }
  return anyEmpty;
}