title: How to change object value in a loop in Dart
body: <p>I'm a total newbie in Dart and I've a lot of issues trying to change a member value of an Object inside a loop.</p>
  
  <p>I've my object so defined:</p>
  
  <pre><code>class Cell {
    int magicnum, x, y;
  
    Cell(this.magicnum);
  
    toString() {
      return ("$magicnum - [$x][$y]");
    }
  }
  </code></pre>
  
  <p>I create a List of List of Cell (2d array) and then I need to fill x and y value according to position of each object in array.</p>
  
  <pre><code>for (int x = 0; x &lt; DIM; x++) {
      for (int y = 0; y &lt; DIM; y++) {      
        grids[x][y].x = x;
        grids[x][y].y = y;      
      }
    }
  </code></pre>
  
  <p>This obviosly doesn't work because in Dart everything (also integer) is an Object and so, all Cell objects in my array have the same x and y value (they all got a reference to the same object).
  How can I do?</p>
  
  <p>Thanks</p>
  
  <p>@julemand101
  Array is made this way:</p>
  
  <pre><code>List&lt;Cell&gt; cells = List&lt;Cell&gt;.generate(DIM, (i) =&gt; Cell(i + 1));
    List&lt;List&lt;Cell&gt;&gt; grids = List&lt;List&lt;Cell&gt;&gt;();
  
    for (int i = 0; i &lt; DIM; i++) {
      grids.add(shuffleCell(cells));
    }
  </code></pre>