manualGrid method

void manualGrid(
  1. int gridWidth,
  2. int gridHeight
)

Implementation

void manualGrid(int gridWidth, int gridHeight) {
  Size sizeG = Size(size.width/gridWidth,size.height/gridHeight);
  List<Rect> rects = [];
  List<Vector3> positions = [];
  int j = 0;
  int k = 0;

  for(int i = 0; i < gridWidth*gridHeight; i++){
    if(i != 0 && i%gridWidth != 0){
      j++;
    }
    else if(i != 0 && i%gridWidth == 0){
      k++;
      j = 0;
    }

    rects.add(Rect.fromLTWH(j*sizeG.width, k*sizeG.height, sizeG.width, sizeG.height));

    Vector3 newPosition =
    position+
    Converter.toVector3(Vector3(0,0,0), Offset(rects[i].left,rects[i].top));
    positions.add(newPosition);
  }

  grid = TileGrid(
    position: positions,
    rects: rects,
    type: GridType.manual,
    width: gridWidth,
    height: gridHeight
  );
  //updateTapLocation(Offset(0,0));
}