Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter how to add a Expandable menu item inside navigation drawer?

I want to add expandable menu to drawer items of flutter. How can I achieve this functionality in flutter. Please just point me in the correct direction if there is any example or blog.

enter image description here

like image 719
Ammy Kang Avatar asked Aug 06 '18 11:08

Ammy Kang


2 Answers

You have to pass the drawers child property a ListView, and in that ListView you can then use an ExpansionTile. That would look something like this:

Drawer(
  child: ListView(
    children: <Widget>[
      ExpansionTile(
        title: Text("Expansion Title"),
        children: <Widget>[Text("children 1"), Text("children 2")],
      )
    ],
  ),
);
like image 177
leodriesch Avatar answered Nov 11 '22 20:11

leodriesch


You have to pass the drawers child property a ListView, and in that ListView you can then use an ExpansionTile. That would look something like this:

ExpansionTile(
              title: Text('Categories'),
              leading: Icon(Icons.view_list),
              children: <Widget>[
                GestureDetector(
                  child: SizedBox(
                    width: 250,
                    height: 35,
                    child: Container(
                      decoration: BoxDecoration(
                      color: Colors.black26,
                      borderRadius: BorderRadius.circular(15),
                      ),
                        child: Card(child: Center(child: Text("Shalwar kameez"))))),
                onTap: (){},
                ),
                SizedBox(height: 7,),
                 GestureDetector(
                   child: SizedBox(
                      width: 250,
                      height: 35,
                      child: Container(
                        decoration: BoxDecoration(
                        color: Colors.black26,
                        borderRadius: BorderRadius.circular(15),
                        ),
                          child: Card(child: Center(child: Text("Sherwani."))))),
                   onTap: (){},),
                SizedBox(height: 7,),
                GestureDetector(
                  child: SizedBox(
                      width: 250,
                      height: 35,
                      child: Container(
                          decoration: BoxDecoration(
                            color: Colors.black26,
                            borderRadius: BorderRadius.circular(15),
                          ),
                          child: Card(child: Center(child: Text("Sindhi Ajrak or Cap."))))),
                  onTap: (){},),
                SizedBox(height: 7,),
                GestureDetector(
                  child: SizedBox(
                      width:250,
                      height: 40,
                      child: Container(
                          decoration: BoxDecoration(
                            color: Colors.black26,
                            borderRadius: BorderRadius.circular(15),
                          ),
                          child: Card(child: Center(child: Text("Punjabi kurta and tehmat."))))),
                  onTap: (){},),
                SizedBox(height: 7,),
                GestureDetector(
                  child: SizedBox(
                      width: 250,
                      height: 35,
                      child: Container(
                          decoration: BoxDecoration(
                            color: Colors.black26,
                            borderRadius: BorderRadius.circular(15),
                          ),
                          child: Card(child: Center(child: Text("Saraiki Turban"))))),
                  onTap: (){},),
                SizedBox(height: 7,),
                GestureDetector(
                  child: SizedBox(
                      width: 250,
                      height: 35,
                      child: Container(
                          decoration: BoxDecoration(
                            color: Colors.black26,
                            borderRadius: BorderRadius.circular(15),
                          ),
                          child: Card(child: Center(child: Text("Saraiki Kurta."))))),
                  onTap: (){},),
                SizedBox(height: 7,),
                GestureDetector(
                  child: SizedBox(
                      width: 250,
                      height: 35,
                      child: Container(
                          decoration: BoxDecoration(
                            color: Colors.black26,
                            borderRadius: BorderRadius.circular(15),
                          ),
                          child: Card(child: Center(child: Text("Peshawari Turban."))))),
                  onTap: (){},),
                SizedBox(height: 7,),
                GestureDetector(
                  child: SizedBox(
                      width: 250,
                      height: 35,
                      child: Container(
                          decoration: BoxDecoration(
                            color: Colors.black26,
                            borderRadius: BorderRadius.circular(15),
                          ),
                          child: Card(child: Center(child: Text("Lehenga Choli"))))),
                  onTap: (){},),

    ],
like image 25
شير دل Avatar answered Nov 11 '22 20:11

شير دل