字幕列表 影片播放 列印英文字幕 [MUSIC PLAYING] KHANH NGUYEN: Need to provide users with a way to select a value from a list of options? Try DropdownButton. To start, give it a list of options as DropdownMenuItems. DropdownMenuItems represent the things you'll actually see in the dropdown menu. Since they're all in a list together, they must all be of the same type. Provide a state variable containing the value of the selected DropdownMenuItem. And finally, give it an onChanged callback that calls setState() to update the variable when a new value is selected. Now, technically, you can stop right there, or you can customize the DropdownButton to your heart's content. Is that arrow too small? Make it bigger by adjusting the icon, Size. Or perhaps the default gray doesn't stand out enough. Give it a splash of color by providing an iconEnabledColor. Don't even like the arrow? Go ahead and replace it with a different icon. Have the dropdown content horizontally fill its parent by enabling isExpanded. And you can even give the text a fresh coat of paint by providing a style. One thing to remember-- if either onChanged or the list of items are null, the DropdownButton gets disabled. The arrow will be grayed out and it won't respond to input. For more info on Flutter and all the other widgets, head to Flutter.dev. [MUSIC PLAYING]
B1 中級 美國腔 Flutter下拉按鈕 (Widget of the Week)(DropdownButton (Widget of the Week)) 9 0 沈占明 發佈於 2022 年 03 月 01 日 更多分享 分享 收藏 回報 影片單字