简体   繁体   English

如何制作动画自定义下拉菜单

[英]how to make an animated custom dropdown menu

So here's my vision, I want my options to all be stacked at first, but then when the user clicks on a button, the container expands from top to bottom, and my options start appearing.所以这是我的愿景,我希望我的选项一开始都是堆叠的,但是当用户点击一个按钮时,容器从上到下展开,我的选项开始出现。 Here I attempted to make my idea clear在这里我试图把我的想法说清楚

在此处输入图像描述

Use dropdown_button2 plugin here is the example使用dropdown_button2插件这里是示例

String selectedValue;
List<String> items = [
  'Item1',
  'Item2',
  'Item3',
  'Item4',
];

DropdownButtonHideUnderline(
  child: DropdownButton2(
    hint: Text(
      'Select Item',
      style: TextStyle(
        fontSize: 14,
        color: Colors.black,
      ),
    ),
    items: items
        .map((item) =>
        DropdownMenuItem<String>(
          value: item,
          child: Text(
            item,
            style: const TextStyle(
              fontSize: 14,
            ),
          ),
        )
    ).toList(),
    value: selectedValue,
    onChanged: (value) {
      setState(() {
        selectedValue = value as String;
      });
    },
    buttonHeight: 40,
    buttonWidth: 140,
    itemHeight: 40,
  ),
),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM