children
.DropDownButton
.DropdownButton
.DropdownMenuItem
. T
is a common class, usually, it is the type of your data. Such as String
, double
. The value will be this class same as the T
. The child will show in the menu. It is a widget, I use a Text in the fore example. In this example, I will use a Row
to show you.isExpanded == true
. It will expand the menu. When you click it, it will show you the right one.1
, 2
. var _value = "1";
If you set it to other value, such _value ="3"
.It will occur such error. value
parameter.onChange
or items
to null, I will show the disabledHint
.elevation
controls the shadow of the menu, we have used it so many time, so I will not tell this again in the other widgets. The style
controls the Text in the menu. The isDense
will reduce the height of the button. The iconSize
controls the size of the triangle-arrow. The result is below.DropdownButton
. It just jumps out a menu to select. It is easy to understand, but need care about the value must be in the range of values of the items.