【问题标题】:how to make drop down menu Flutter如何使下拉菜单颤动
【发布时间】:2023-03-13 08:53:01
【问题描述】:

如何在颤振中制作这样的下拉菜单??

以及如何将任何项目添加到该菜单中??

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    有一个Widget 称为DropDownButton。有关更多信息,请查看该小部件的 docs。您可以通过将List<DropdownMenuItem<T>> 传递给菜单的items 参数来将项目添加到菜单中。

    DropdownButton<String>(
          value: dropdownValue,
          icon: Icon(Icons.arrow_downward),
          iconSize: 24,
          elevation: 16,
          style: TextStyle(color: Colors.deepPurple),
          underline: Container(
            height: 2,
            color: Colors.deepPurpleAccent,
          ),
          onChanged: (String newValue) {
            setState(() {
              dropdownValue = newValue;
            });
          },
          items: <String>['One', 'Two', 'Free', 'Four']
              .map<DropdownMenuItem<String>>((String value) {
            return DropdownMenuItem<String>(
              value: value,
              child: Text(value),
            );
          }).toList(),
        );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-30
      • 1970-01-01
      • 1970-01-01
      • 2021-09-17
      • 2021-11-04
      • 1970-01-01
      • 2021-08-28
      相关资源
      最近更新 更多