copyFrom method

void copyFrom(
  1. Grid<E> src, {
  2. Rect? source,
  3. Pos target = Pos.zero,
})

Copies the elements from another grid into this grid.

If source is provided, only the elements within the bounds are copied.

A target offset can be provided to copy the elements to a different position in this grid.

Implementation

void copyFrom(Grid<E> src, {Rect? source, Pos target = Pos.zero}) {
  final dst = this;
  if (source == null) {
    source = src.bounds;
  } else {
    source = bounds.intersect(src.bounds);
  }
  copyRect(
    source,
    src.get,
    dst.set,
    target: target,
  );
}