addCell method

MergeCell addCell(
  1. MergeCell mergeCell
)

Add merged cell to the collection.

Implementation

MergeCell addCell(MergeCell mergeCell) {
  bool inserted = false;
  int count = 0;
  for (final MergeCell mCell in innerList) {
    if (MergedCellCollection._isIntersecting(mCell, mergeCell)) {
      final MergeCell intersectingCell = MergeCell();
      intersectingCell.x = min(mCell.x, mergeCell.x);
      intersectingCell.y = min(mCell.y, mergeCell.y);
      intersectingCell.width =
          max(mCell.width + mCell.y, mergeCell.width + mergeCell.x);
      intersectingCell.height =
          max(mCell.height + mCell.y, mergeCell.height + mergeCell.y);
      intersectingCell._reference =
          '${this[count]._reference.split(':')[0]}:${mergeCell._reference.split(':')[1]}';
      innerList[count] = intersectingCell;
      mergeCell = intersectingCell;
      inserted = true;
    }
    count++;
  }
  if (!inserted) {
    innerList.add(mergeCell);
  }
  return mergeCell;
}