Creating a DropdownButton widget

DropdownButton is a widget that lets users select a value from a list of items. DropdownButton shows the currently selected item, as well as a small triangle that opens a list for selecting another item.

Here are the steps that are required to add DropdownButton to your apps:

  1. Create an instance of DropdownButton, specifying the type of data that will be included in the list.
  2. Add an items property that will contain the list of items that will be shown to the user.
  1. The items property requires a list of DropdownMenuItem widgets. Therefore, you need to map each value that you want to show into DropdownMenuItem.
  2. Respond to the user actions by specifying an event; typically, for DropdownButton, you will call ...

Get Flutter Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.