Flutter onPressed of a Button on a ListView gets called automatically (when it becomes visible). Is this a bug? : <p>As the title mentions <code>onPressed</code> of a Button on a ListView gets called automatically</p>

<p>I currently have something like this (this is a rough sketch of the code).
Basically whenever there is a button in each row and whenever a button gets displayed on the screen its onClick is called. Not sure if this is a bug in flutter or I am doing something wrong any suggestions ?</p>

<pre><code>class ModelEmployeeRow extends StatelessWidget
{

    dynamic getInviteButton(String text, {var lambda,var borderRadius,var height})
    {
        final skillTextStyle = baseTextStyle.copyWith(
                color: Colors.white,//const Color(0xffb6b2df),
                fontSize: 11.0,
                fontWeight: FontWeight.w200
                );

        var container = new Container(
            alignment: Alignment.center,
            margin:EdgeInsets.fromLTRB(0.0,0.0,100.0,0.0),
            padding:EdgeInsets.fromLTRB(0.0,5.0,0.0,5.0),
            decoration: new BoxDecoration(
                borderRadius: new BorderRadius.all(new Radius.circular(4.0)),
                color: Colors.green
                ),
            child: new Text(text, style:skillTextStyle),
            );


        var button = new FlatButton(
                onPressed: inviteClicked(employee),
                child: container
                );

        return button;
    }


    @override
    Widget build(BuildContext context)
    {
        var stacked =  new Stack(
            children: &lt;Widget&gt;
            [
                //mainContainer,
                getInviteButton("Test"),
                employeeThumbnail,
            ],
            );

        return new Container(
            child: stacked,
            );

    }

}
</code></pre>

<p>and the list view side is this</p>

<pre><code> var emplyeeListView = new ListView.builder(
            itemCount: employeeListShared.length,
            padding: new EdgeInsets.symmetric(vertical: 16.0),
            itemBuilder: (context, index) {
                return new ModelEmployeeRow(employeeListShared[index]);
            },
            );
</code></pre>

<p>Now when ever a row gets visible the onclick of the button is called.</p>
