title: Flutter GestureDetector, onTap gets triggered automatically, how to?
body: <p>I have a stateful widget that has a simple grid and each grid cell has a container inside it.</p>
  
  <p>I would like to click on a cell / container and have its content changed.</p>
  
  <p>The problem is that the GestureDetector -> onTap method gets triggered on app refresh for all cels.</p>
  
  <p>In the example below, the <code>_changeCell</code> method gets triggered instantly for all cels and <code>onTap</code> doesn't work.</p>
  
  <p>Any ideas?</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  class GridWidget extends StatefulWidget {
    @override
    _GridWidgetState createState() =&gt; new _GridWidgetState();
  }
  
  class _GridWidgetState extends State&lt;GridWidget&gt; {
    @override
    Widget build(BuildContext context) {
  
      Color cellColor = Colors.white;
      Text cellText = new Text('');
  
      // when a cell is tapped, change the color and text
      _changeCell(index) {
        setState(() {
          cellColor = Colors.lightBlue;
          cellText = new Text('clicked');
        });
        print("Container clicked " + index.toString());
      }
  
      // create a 5 by 5 grid 
      return new GridView.count(
        crossAxisCount: 5,
        children: new List.generate(5, (index) {
          return new GestureDetector(
            onTap: _changeCell(index),
            child: new Container(
              width: double.infinity,
              height: double.infinity,
              decoration: new BoxDecoration(
                color: cellColor,
              ),
              child: new Center(
                child: cellText,
              ),
            ),
          );
        }),
      );
    }
  }
  </code></pre>