how to create sub dropdown menu in flutter drawer

Viewed 1121

hello everyone I am creating a dropdown in the flutter drawer, For example, I add 4 to 5 Text in the column widget but the question is how I can create the submenu of every Text. Thanks in Advance

1 Answers

Try below code hope its helpful to you.

 return Scaffold(
  appBar: AppBar(title: Text(title)),
  body: const Center(
    child: Text('My Page!'),
  ),
  drawer: Drawer(
    child: ListView(
      padding: EdgeInsets.zero,
      children: [
        const DrawerHeader(
          decoration: BoxDecoration(
            color: Colors.blue,
          ),
          child: Text('Drawer Header'),
        ),
        ExpansionTile(
          title: Text('Heading'),
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 16.0),
              child: Align(
                alignment: Alignment.topLeft,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    Text('subHeading1'),
                    Text('subHeading2')
                  ],
                ),
              ),
            ),
          ],
        ),
        ExpansionTile(
          title: Text('Heding'),
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 16.0),
              child: Align(
                alignment: Alignment.topLeft,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    Text('subHeading1'),
                    Text('subHeading2')
                  ],
                ),
              ),
            ),
          ],
        ),
      ],
    ),
  ),
);

Or you can use multilevel_drawer here and expandable_tree_menu here

Your result-> enter image description here

Related