How to create submenu dropdown in flutter

2,117

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")],
  )
 ],
 ),
);
Share:
2,117

Related videos on Youtube

isofttechn
Author by

isofttechn

Updated on December 02, 2022

Comments

  • isofttechn
    isofttechn over 1 year

    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

    • Deer Hunter
      Deer Hunter about 9 years
      Have you asked your vendor for support?
    • Chopper3
      Chopper3 about 9 years
      I have exactly the same printer at home and my daughter uses Tray 1 for printing photos - this isn't via W2012 of course but she chooses regular A4 - not the preprinted version/type - have you tried that as it works for her.
    • Jan
      Jan about 9 years
      @Chopper3: I will try setting Tray 1 to A4 Plain. Will report back.
    • Jan
      Jan about 9 years
      @Chopper: Changed the setting to "Plain", still getting the prompt :(.
    • Michael Hampton
      Michael Hampton about 9 years
      Shouldn't the manual feed always prompt you though? I'd consider getting the extra tray for this printer, rather than expecting the manual feed to be automatic.
  • isofttechn
    isofttechn almost 3 years
    Now that I have my MenuItem class, how do I fit in the MLMenuItem with subMenuItems without conflicting with mine?
  • Ravindra S. Patil
    Ravindra S. Patil almost 3 years
    Try MenuItem( icon: Icons.sensor_window, title: 'Sensor Parameters', ), replace by text widget inside children of expansiontile
  • isofttechn
    isofttechn almost 3 years
    I am getting this error: RenderBox was not laid out: RenderSemanticsAnnotations#25c5c relayoutBoundary=up13 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:flutter/src/rendering/box.dart': Failed assertion: line 1940 pos 12: 'hasSize'
  • Ravindra S. Patil
    Ravindra S. Patil almost 3 years
    Try to add your MenuItem inside Expanded or Flexible Widget like as Expanded(child:MenuItem(icon: Icons.sensor_window,title: 'Sensor Parameters',),),