0
0
Fluttermobile~5 mins

DropdownButton in Flutter - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a DropdownButton in Flutter?
A DropdownButton is a widget that shows a list of options when tapped, allowing the user to select one option from the list.
Click to reveal answer
beginner
How do you provide the list of options to a DropdownButton?
You provide a list of DropdownMenuItem widgets to the items property of the DropdownButton. Each item represents one selectable option.
Click to reveal answer
beginner
What property of DropdownButton holds the currently selected value?
The value property holds the currently selected item from the list of options.
Click to reveal answer
beginner
How do you update the selected value when the user picks a new option?
You use the onChanged callback, which receives the new selected value. Inside it, you update the state to reflect the new selection.
Click to reveal answer
beginner
Why should you use DropdownMenuItem widgets inside DropdownButton?
Because DropdownMenuItem defines each option's value and how it looks in the dropdown list, making the dropdown interactive and meaningful.
Click to reveal answer
Which property of DropdownButton sets the list of selectable options?
AonChanged
Bvalue
Cselected
Ditems
What type of widget is used to represent each option inside a DropdownButton?
ADropdownMenuItem
BDropdownOption
CDropdownEntry
DDropdownChoice
How do you detect when the user selects a new option in a DropdownButton?
AUsing the <code>onTap</code> callback
BUsing the <code>onSelect</code> property
CUsing the <code>onChanged</code> callback
DUsing the <code>onPressed</code> property
What happens if the value property of DropdownButton is null?
AThe dropdown crashes
BThe dropdown shows no selected item
CThe dropdown shows the first item selected
DThe dropdown disables itself
Which of these is NOT a required property for a basic DropdownButton?
Aicon
Bvalue
ConChanged
Ditems
Explain how to create a simple dropdown menu in Flutter using DropdownButton.
Think about how you show options, track the selected one, and respond to user taps.
You got /5 concepts.
    Describe the role of the onChanged callback in a DropdownButton.
    It is how your app knows the user picked a different option.
    You got /4 concepts.