Search code examples
flutterflutter-layoutnavigation-drawer

Horizontal sliding menu item in navigation draw in flutter?


I am new to flutter. Is it possible to create horizontal sliding menu item in navigation drawer in flutter ? If possible, how to archive this widget ? I am providing the UI below

image


Solution

  • It can be using ListView inside Drawer, in this case you need to provide height for ListView

    
    class AppDrawer extends StatelessWidget {
      const AppDrawer({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Drawer(
          child: Column(
            children: [
              DrawerHeader(
                  child: Column(
                children: [
                  Text("Logo"),
                  SizedBox(
                    height: 50, // the amount you want
                    child: ListView.builder(
                      scrollDirection: Axis.horizontal,
                      itemCount: 12,
                      itemBuilder: (context, index) => Container(
                        decoration: BoxDecoration(
                          border: Border.all(color: Colors.green),
                          borderRadius: BorderRadius.circular(12),
                        ),
                        margin: EdgeInsets.only(right: 10),
                        padding: EdgeInsets.all(12),
                        child: Text("item $index"),
                      ),
                    ),
                  )
                ],
              ))
            ],
          ),
        );
      }
    }
    
    

    And use

      return Scaffold(
            drawer: AppDrawer(),