Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create submenu dropdown in flutter

I am working on sidebar in flutter, I need to add a submenu to the alreay existing menu Items.

I have two files, menu_items.dart and sidebar.dart. Menu_Items codes:

import 'package:flutter/material.dart';

class MenuItem extends StatelessWidget {
  const MenuItem({Key key, this.icon, this.title, this.onTap})
      : super(key: key);
  final IconData icon;
  final String title;
  final Function onTap;
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Padding(
        padding: const EdgeInsets.all(16),
        child: Row(
          children: [
            Icon(
              icon,
              color: Colors.white,
              size: 20,
            ),
            SizedBox(
              width: 20,
            ),
            Text(
              title,
              style: TextStyle(
                fontWeight: FontWeight.w300,
                fontSize: 15,
                color: Colors.white,
              ),
            ),
          ],
        ),
      ),
    );
  }
}

This is how I am using it in Sidebar.dart:

   MenuItem(
      icon: Icons.sensor_window,
      title: 'Sensor Parameters',
      ),

The thing is, I need to make the sensor parameter

enter image description here

a parent dropdown, with a list of menu items that I already have. The sub-menu dropdown Items are:

TemChartClickEvent,
 HumChartClickEvent,
 MoisChartClickEvent,
 PhChartClickEvent,
 NurChartClickEvent,
 GasChartClickEvent,

Which are created using bloc patterns. The parent menu:

MenuItem(
      icon: Icons.sensor_window,
      title: 'Sensor Parameters',
      ),

I have been sourcing the internet to get a good resource and make up the menu, but, I couldn't get it to work.

Anyone can help me set it up, giving that I already have MenuItem code above, how do I fit in another bunch of codes call DropDownMenu with its functions, and then pass it into the parent menu, "MenuItem" code above

like image 364
isofttechn Avatar asked Oct 19 '25 10:10

isofttechn


1 Answers

You have pass ExpansionTile Widget Or Used multilevel_drawer package

Drawer(
  child: ListView(
  children: <Widget>[
  ExpansionTile(
  title: Text("Expansion Title"),
    children: <Widget>[Text("children 1"), Text("children 2")],
  )
 ],
 ),
);
like image 103
Ravindra S. Patil Avatar answered Oct 20 '25 23:10

Ravindra S. Patil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!