Flutter Button Series: PopupMenuButton

Tram Ho

Hi everyone, welcome to the Button series in Flutter, today I will introduce about PopupMenuButton.

  1. ButtonBar
  2. DropdownButton
  3. FlatButton
  4. FloatingActionButton
  5. IconButton
  6. PopupMenuButton
  7. RaisedButton

The popup menu is used to display a list of popup items, when an item is selected, the popup menu will disappear. The value of the selected item will pass via the onSelected () callback.

Check out the properties of PopupMenuButton

PropertiesMeaning
childIf this property is provided, the widget will be used for the button
elevationSee more here
enableThis property is non-null, with a default value of true, it can now be interacted. If this property is set to false, the popup will be in a non-interactive state, and set the style to disable from the current theme in use. onSelected, onCanceled, itemBuilder will no longer be called
IconIf this property is provided, the icon will be used for the button
initalValueInitialize the default display value for the popup menu, and it will be highlighted in the item list when shown
itemBuilderThis callback is called when you click the button to create a list of items
offsetSee more here
onCanceledThis callback is called when the popup disappears without selecting any item
onSelectedThis call back is called when the popup disappears and an item is selected at the same time
paddingPadding settings for button icons
tooltipUsed to define the description when an action press on the button. It will appear if the user is long-pressed

Above I have introduced to you the most basic about PopupMunuButton. By now, you should have a good grasp of it. And here I will make some small code to illustrate home.

OK, so my introduction to PopupMenuButton is here for the end. See you in the other posts. Happy coding ?

Series:

  1. ButtonBar
  2. DropdownButton
  3. FlatButton
  4. FloatingActionButton
  5. IconButton
  6. PopupMenuButton
  7. RaisedButton

Reference: PopupMenuButton.class

Share the news now

Source : Viblo