title: Programmatically expand ExpansionTile in Flutter
body: <p>I’m just trying to use <code>ExpansionTile</code> in Flutter, from example I modified to become like this:</p>
  
  <p><a href="https://i.stack.imgur.com/5EJUMm.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/5EJUMm.jpg" alt="enter image description here"></a></p>
  
  <p>I want to hide the arrow and use <code>Switch</code> to expand the tile, is it possible? Or do I need custom widget which render children programmatically? Basically, I just need to show/hide the children</p>
  
  <p>Here’s my code:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  void main() {
    runApp(ExpansionTileSample());
  }
  class ExpansionTileSample extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            title: const Text('ExpansionTile'),
          ),
          body: ListView.builder(
            itemBuilder: (BuildContext context, int index) =&gt;
                EntryItem(data[index]),
            itemCount: data.length,
          ),
        ),
      );
    }
  }
  
  // One entry in the multilevel list displayed by this app.
  class Entry {
    Entry(this.title,[this.question='',this.children = const &lt;Entry&gt;[]]);
  
    final String title;
    final String question;
    final List&lt;Entry&gt; children;
  }
  
  // The entire multilevel list displayed by this app.
  final List&lt;Entry&gt; data = &lt;Entry&gt;[
    Entry(
      'Chapter A',
      '',
      &lt;Entry&gt;[
        Entry(
          'Section A0',
          '',
          &lt;Entry&gt;[
            Entry('Item A0.1'),
            Entry('Item A0.2'),
            Entry('Item A0.3'),
          ],
        ),
        Entry('Section A1','text'),
        Entry('Section A2'),
      ],
    ),
    Entry(
      'Chapter B',
      '',
      &lt;Entry&gt;[
        Entry('Section B0'),
        Entry('Section B1'),
      ],
    ),
    Entry(
      'Chapter C',
      '',
      &lt;Entry&gt;[
        Entry('Section C0'),
        Entry('Section C1')
      ],
    ),
  ];
  
  // Displays one Entry. If the entry has children then it's displayed
  // with an ExpansionTile.
  class EntryItem extends StatelessWidget {
    const EntryItem(this.entry);
  
    final Entry entry;
  
    Widget _buildTiles(Entry root) {
      if (root.children.isEmpty) return  Container(
          child:Padding(
            padding: const EdgeInsets.symmetric(
              vertical: 8.0,
              horizontal: 32.0,
            ),
            child:Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children:[
                    Text(root.title),
                    Divider(height: 10.0,),
                    root.question=='text'?Container(
                        width: 100.0,
                        child:TextField(
                          decoration: const InputDecoration(helperText: "question")
                        ),
                    ):Divider()
                ]
            )
          )
      );
      return ExpansionTile(
        //key: PageStorageKey&lt;Entry&gt;(root),
        title: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children:[
            Text(root.title),
            Switch(
              value:false,
              onChanged: (_){},
            )
          ]
        ),
        children: root.children.map(_buildTiles).toList(),
      );
    }
  
    @override
    Widget build(BuildContext context) {
      return _buildTiles(entry);
    }
  }
  </code></pre>