title: Increment counter for each Grid View using the parameters (Flutter)
body: <p>I have a widget with the parameters to create the grid that I want to like the name or the gradient that I want, I added a new parameter to send a variable to increments it when I press a button or decrease it. There is a problem the increment is not working when I call it and stuck one number higher and one lower, but it works if I change the 'counter' in the widget not the parameter but the onPressed to any of the variables below, but the counter in all the grid view will change to one variable.</p>
  
  <p><a href="https://imgur.com/h1C89dk" rel="nofollow noreferrer">https://imgur.com/h1C89dk</a> "Screenshot"</p>
  
  <p>Here is the code: 
  this is the variables</p>
  
  <pre><code> int thoub = 0,
    shirt = 0,
    longPants = 0,
    shortPants = 0,
    shumgnGutr = 0,
    socks = 0,
    bsht = 0,
    tShirt = 0,
    miltUniform = 0,
    pakisUniform = 0,
    singleBlankets = 0,
    doubleBlankets = 0,
    abbya = 0;
  </code></pre>
  
  <p>here is when I call the widget: </p>
  
  <pre><code>myGridItems(
          'ثياب', //Arabic
          Colors.deepPurple.withOpacity(0.2),
          Colors.grey[300].withOpacity(0.35),
          thoub,
        ),
  myGridItems(
          'فنايل', //Arabic
          Colors.deepPurple.withOpacity(0.2),
          Colors.grey[300].withOpacity(0.35),
          shirt,
        ),
  </code></pre>
  
  <p>and this is the widget itself:</p>
  
  <pre><code>Widget myGridItems(String gridName, Color color1, Color color2, int counter) {
  return Container(
    decoration: BoxDecoration(
      gradient: LinearGradient(colors: [
        color1,
        color2,
      ], begin: Alignment.topLeft, end: new Alignment(1.0, 1.0)),
    ),
    child: Stack(
      children: &lt;Widget&gt;[
        Opacity(
          opacity: 0.3,
          child: Container(
            decoration: BoxDecoration(),
          ),
        ),
        Column(
          children: &lt;Widget&gt;[
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: &lt;Widget&gt;[
                FlatButton(
                  onPressed: () {
                    setState(() {
                      if (counter != 50) counter++;
                      debugPrint('$counter');
                      print('add on pressed');
                    });
                  },
                  child: Icon(
                    Icons.add,
                    color: Colors.green,
                    size: 17.0,
                  ),
                ),
                Text('$counter',
                    style: TextStyle(fontSize: 18.0, color: Colors.blueGrey)),
                FlatButton(
                  onPressed: () {
                    setState(() {
                      if (counter != 0) counter--;
                      debugPrint('$counter');
                      print('minus on pressed');
                    });
                  },
                  child: Icon(
                    const IconData(0xe15b, fontFamily: 'MaterialIcons'),
                    color: Colors.red,
                    size: 17.0,
                  ),
                ),
                Column(
                  children: &lt;Widget&gt;[
                    Container(
                      width: MediaQuery.of(context).size.width / 2,
                      child: Padding(
                        padding:
                            const EdgeInsets.fromLTRB(0.0, 10.0, 15.0, 0.0),
                        child: Text(
                          gridName,
                          style: TextStyle(
                            color: Colors.black54,
                            fontSize: 20.0,
                            fontWeight: FontWeight.bold,
                          ),
                          textAlign: TextAlign.right,
                        ),
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ],
        )
      ],
    ),
  );
    }
  </code></pre>
  
  <p>this is the terminal</p>
  
  <pre><code>I/flutter (17441): 1
  I/flutter (17441): add on pressed
  I/flutter (17441): 0
  I/flutter (17441): minus on pressed
  I/flutter (17441): 1
  I/flutter (17441): add on pressed
  I/flutter (17441): 1
  I/flutter (17441): add on pressed
  </code></pre>