Flutter - Collapsing ExpansionTile after choosing an item : <p>I'm trying to get <code>ExpansionTile</code> to collapse after I choose an item, but it does not close the list that was opened.</p>

<p>I tried to use the <code>onExpansionChanged</code> property but I did not succeed</p>

<p>How could you solve this problem?</p>

<p>Insert a gif demonstrating that <code>ExpansionTile</code> does not collapse after choosing an item, and below is also the code used.</p>

<p><a href="https://i.stack.imgur.com/WNjaz.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/WNjaz.gif" alt="enter image description here"></a></p>

<pre><code>import 'package:flutter/material.dart';

void main() {
  runApp(new ExpansionTileSample());
}

class ExpansionTileSample extends StatefulWidget {
  @override
  ExpansionTileSampleState createState() =&gt; new ExpansionTileSampleState();
}

class ExpansionTileSampleState extends State&lt;ExpansionTileSample&gt; {
  String foos = 'One';

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('ExpansionTile'),
        ),
        body: new ExpansionTile(
          title: new Text(this.foos),
          backgroundColor: Theme.of(context).accentColor.withOpacity(0.025),
          children: &lt;Widget&gt;[
            new ListTile(
              title: const Text('One'),
              onTap: () {
                setState(() {
                  this.foos = 'One';
                });
              },              
            ),
            new ListTile(
              title: const Text('Two'),
              onTap: () {
                setState(() {
                  this.foos = 'Two';
                });
              },              
            ),
            new ListTile(
              title: const Text('Three'),
              onTap: () {
                setState(() {
                  this.foos = 'Three';
                });
              },              
            ),
          ]
        ),
      ),
    );
  }
}
</code></pre>
