title: Flutter: `onPressed` acts on all `IconButton`s in a list view
body: <p>I want to change color of every icon after pressing. But all of icons in a <code>ExpandableContainer</code>change after pressing one of them. </p>
  
  <pre><code>class _ExpandableListViewState extends State&lt;ExpandableListView&gt; {
    bool expandFlag = false;
    Color _iconColor = Colors.white;
  
    @override
    Widget build(BuildContext context) {
      return new Container(
        margin: new EdgeInsets.symmetric(vertical: 1.0),
        child: new Column(
          children: &lt;Widget&gt;[
            new Container(
                 .
                 .
                 .
                 ),
            new ExpandableContainer(              
                expanded: expandFlag,
                expandedHeight: ...              
                child: new ListView.builder(
                  itemBuilder: (BuildContext context, int index) {
                    return new Container(
                      decoration:
                          new BoxDecoration(border: new Border.all(width: 1.0, color: Colors.grey), color: Colors.black),                        
                       child: new ListTile(
                         title: ...
  
                         leading: new IconButton(
                          icon: Icon(Icons.star, color: _iconColor),
                          onPressed: () {
                            setState(() {                           
                             _iconColor = _iconColor == Colors.white ? Colors.yellow : Colors.white;                           
                            });
                          },
                        ),                                            
                        subtitle: ...                                                 
                    ), 
                    );
                  },
                  itemCount: ...,
                ))
          ],
        ),
      );
    }
  }
  
  class ExpandableContainer extends StatelessWidget {
    final bool expanded;
    final double expandedHeight;
    final Widget child;
  
    ExpandableContainer({
      @required this.child,
      this.expandedHeight,
      this.expanded = true,
    });
  
    @override
    Widget build(BuildContext context) {
  .
  .
  .
  }
  </code></pre>
  
  <p>Whole code:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'data.dart';
  
  void main() {
    runApp(new MaterialApp(home: new Home()));
  }
  
  class Home extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return new Scaffold(
        backgroundColor: Colors.grey,
        appBar: new AppBar(
          title: new Text("Expandable List", style: TextStyle(color: Colors.black)),
          backgroundColor: Colors.lightGreen,
        ),
        body: new ListView.builder(
          itemBuilder: (BuildContext context, int index) {
            return new ExpandableListView(title: broadcast[index].title, ind: index);
          },
          itemCount: broadcast.length,
        ),
      );
    }
  }
  
  class ExpandableListView extends StatefulWidget {
    final String title;
    final int ind;
  
    const ExpandableListView({this.title, this.ind});
  
    @override
    _ExpandableListViewState createState() =&gt; new _ExpandableListViewState();
  }
  
  class _ExpandableListViewState extends State&lt;ExpandableListView&gt; {
    bool expandFlag = false;
    Color _iconColor = Colors.white;
  
    @override
    Widget build(BuildContext context) {
      return new Container(
        margin: new EdgeInsets.symmetric(vertical: 1.0),
        child: new Column(
          children: &lt;Widget&gt;[
            new Container(
              color: Colors.blue[300],
              padding: new EdgeInsets.symmetric(horizontal: 5.0),
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: &lt;Widget&gt;[
                  new IconButton(
                      icon: new Container(
                        height: 50.0,
                        width: 50.0,
                        decoration: new BoxDecoration(
                          color: Colors.deepOrange,
                          shape: BoxShape.circle,
                        ),
                        child: new Center(
                          child: new Icon(
                            expandFlag ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down,
                            color: Colors.white,
                            size: 30.0,
                          ),
                        ),
                      ),
                      onPressed: () {
                        setState(() {
                          expandFlag = !expandFlag;
                        });
                      }),
                  new Text(
                    widget.title,
                    style: new TextStyle(fontWeight: FontWeight.bold,fontSize: 20.0, color: Colors.black87),
                  )
                ],
              ),
            ),
            new ExpandableContainer(              
                expanded: expandFlag,
                expandedHeight: 90.0 * (broadcast[widget.ind].contents.length &lt; 4 ? broadcast[widget.ind].contents.length : 4), // + (0.0 ?: 29.0),              
                child: new ListView.builder(
                  itemBuilder: (BuildContext context, int index) {
                    return new Container(
                      decoration:
                          new BoxDecoration(border: new Border.all(width: 1.0, color: Colors.grey), color: Colors.black),                        
                       child: new ListTile(
                        title: new Text(
                          broadcast[widget.ind].contents[index],
                          style: new TextStyle(fontWeight: FontWeight.bold, color: Colors.lightGreen),
                          textAlign: TextAlign.right,
                        ),
                         leading: new IconButton(
                          icon: Icon(Icons.star, color: _iconColor),
                          onPressed: () {
                            setState(() {                           
                             _iconColor = _iconColor == Colors.white ? Colors.yellow : Colors.white;                           
                            });
                          },
                        ),                                            
                        subtitle: new Text ('${broadcast[widget.ind].team[index]}\n${broadcast[widget.ind].time[index]}          ${broadcast[widget.ind].channel[index]}',
                        textAlign: TextAlign.right, style:TextStyle(color: Colors.white)),
                        isThreeLine: true,                       
                    ), 
                    );
                  },
                  itemCount: broadcast[widget.ind].contents.length,
                ))
          ],
        ),
      );
    }
  }
  
  class ExpandableContainer extends StatelessWidget {
    final bool expanded;
    final double expandedHeight;
    final Widget child;
    //final Color iconColor;
  
    ExpandableContainer({
      @required this.child,
      this.expandedHeight,
      this.expanded = true,
      //this.iconColor,
    });
  
    @override
    Widget build(BuildContext context) {
      double screenWidth = MediaQuery.of(context).size.width;
      return new AnimatedContainer(
        duration: new Duration(milliseconds: 100),
        curve: Curves.easeInOut,
        width: screenWidth,
        height: expanded ? expandedHeight : 0.0,
        child: new Container(
          child: child,
          decoration: new BoxDecoration(border: new Border.all(width: 1.0, color: Colors.blue)),
        ),
      );
    }
  }
  </code></pre>