getSegment method

List<Cell> getSegment(
  1. Position position
)

Returns a list of Cell at segment defined by position.segment

Implementation

List<Cell> getSegment(Position position) {
  throwIfInvalid(position);
  List<Cell> _tmpSeg = [];

  for (int rInc = 0; rInc < 3; rInc++) {
    for (int cInc = 0; cInc < 3; cInc++) {
      _tmpSeg.add(_matrix![(position.segment!.x * 3) + rInc as int]
          [(position.segment!.y * 3) + cInc as int]);
    }
  }
  return _tmpSeg;
}