Reputation: 512
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
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
Upvotes: 2
Views: 5388
Reputation: 14885
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")],
)
],
),
);
Upvotes: 2