Menu Sample — Flutter

Mathiazhagan Dinesh
1 min readJul 25, 2022

--

In the previous stories, we have learned to create a form using dart in the flutter framework. In this story, we are going to create a sample menu list.

PopupMenuButton

PopupMenuButton is used to show the menu button, the list of options in the menu and the callback onSelected for the respective action.

PopupMenuButton should be added under actions in the appbar to show the menu button in the appbar. Using itemBuilder we are creating the list of menu items. For each menu item, we are adding a PopupMenuItem and inside the PopupMenuItem, we have value and child to hold the text of the menu. When the menu is selected, the onSelected callback is passed with the value.

onSelectedMenu(item)

I have created a method onSelectedMenu(item) to handle the onSelected callback and using the SnackBar to show the menu selected.

Yes, it is that simple to create a menu list in the flutter. You can find the full code in the above mentioned code pen link. Happy coding!

--

--

No responses yet