This article explains you how to create popup menu in flutter applications to show options to users. Popup Menu is used to display drop down menu to users in app bar or other part of UI.
We can navigate user to other pages after selection of any particular item in popup menu. We can also add options manually or dynamically in popup menu in flutter applications.
There are many properties of popup menu such as itemBuilder, initialValue, elevation, onSelected, onCanceled etc. itemBuilder is used to make list of items. initialValue property highlights a value by default. We can change value using this property.
onSelected property is used to navigate to other pages in flutter applications based on user selection. onCanceled property is called when user does not select any value from dropdown menu.
We use PopupMenuButton widget to display dropdown widget in flutter applications. PopupMenuItem widget is used to display UI part in popup menu in flutter applications.
When we click on popup menu item then onSelected method will be called. We also get value from onSelected method so we can navigate user to new screens according to this value. In this example, we are displaying list of football players with options icon.