expandToFit method

GridWorld expandToFit(
  1. int width,
  2. int height
)

Copy this, expanding to fit. Throws exception if world is already too big to fit.

Implementation

GridWorld expandToFit(int width, int height) {
  if (_numCols > width) {
    throw ArgumentError('world too wide ($_numCols) to expand into $width');
  }
  if (_numRows > height) {
    throw ArgumentError('world too tall ($_numRows) to expand into $height');
  }
  final padW = _padding(width, _numCols);
  final padH = _padding(height, _numRows);
  return padLeft(padW.item1)
      .padRight(padW.item2)
      .padTop(padH.item1)
      .padBottom(padH.item2);
}