Reputation: 313
I'm new to Flutter, I have a list of MenuItems
in Drawer
like below.
MenuItem selectedMenuItem;
List<MenuItem> menuItems = [
MenuItem(title: 'Contact', items: [
MenuItem(title: 'Contact Us'),
MenuItem(title: 'Call center'),
MenuItem(title: 'WhatsApp'),
]),
MenuItem(title: 'language'),
MenuItem(title: 'Customer'),
];
I want to open a different page when each item is clicked. What should be my next step? Any ideas?
subItems(BuildContext context) {
return selectedMenuItem.items.map(
(item) => MaterialButton(
onPressed: () {
redirectItem(item);
},
child: Row(
children: [
Text(
item.title,
),
],
),
),
);
} style: TextStyle(fontSize: 14),
);
}
Upvotes: 1
Views: 1020
Reputation: 6144
Welcome to the Flutter Community! I don't see your complete code so I guess you're already able to perform something when onPressed() is triggered.
You can navigate to another widget using this code:
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => YourWidget(),
),
);
},
Upvotes: 1