user13182526
user13182526

Reputation: 47

Open collapsed ListTile after choose row

How could I do so that on the onTap of the line I open another ListTile below?

return ListTile(
              title: Html(data: "<br/> <b>${team[index]['code']}</b>"),
              trailing: Icon(Icons.keyboard_arrow_right),
              onTap: () {
                setState(() {
                  // call open colapsed or child listtile here
                });
              },
            );

Upvotes: 0

Views: 40

Answers (1)

Omer Celik
Omer Celik

Reputation: 319

If I understand your question correctly, you want to show more ListTile items when the user taps on one of the ListTile items?

If that's the case, you can use ExpansionTile instead.

Here is an example code:

ExpansionTile(
  onExpansionChanged: (res) {
    print(res ? 'Open' : 'Close');
  },
  title: Text('Dropdown'),
  children: [
    ListTile(
      title: Text('Test #1'),
      trailing: Icon(Icons.keyboard_arrow_right),
      onTap: () {
        print('Test #1');
      },
    ),
    ListTile(
      title: Text('Test #1'),
      trailing: Icon(Icons.keyboard_arrow_right),
      onTap: () {
        print('Test #1');
      },
    ),
  ],
)

enter image description here

P.S. You can also nest ExpansionTile inside another ExpansionTile.

Upvotes: 1

Related Questions