如何在带有颜色的Flutter上设置必需的DropDownButton?

时间:2019-05-02 07:07:30

标签: dart flutter flutter-layout flutter-animation

我发展了这样的下拉菜单。一切正常。默认情况下,下拉菜单不选择任何值。如何设置红色边框或类似装饰的值等于null(不选择)。 我的下拉代码和图片

  

enter image description here

 Align(
            alignment: Alignment.bottomLeft,
            child: Container(
              child: Text('Priority',
                  style: TextStyle(fontWeight: FontWeight.w400)),
            ),
          ),
          // dropBox(),
          Container(
            //  width: 200.0,
            child: ButtonTheme(
              alignedDropdown: true,
              child: DropdownButton<Priority>(
                isExpanded: true,
                value: _priorities,
                //hint: Text("Select"),
                items: priority.map((Priority value) {
                  return DropdownMenuItem<Priority>(
                    value: value,
                    child: Text(
                      value.description,
                      overflow: TextOverflow.ellipsis,
                    ),
                  );
                }).toList(),
                onChanged: (value) => setState(() {
                      priorityIndex = value.id;
                      _priorities = value;
                    }),

             style: Theme.of(context).textTheme.title,
              ),
            ),
          ),

我需要这个下拉列表,

enter image description here

1 个答案:

答案 0 :(得分:1)

您已经快要在那里了。您已经用.env包裹了DropdownButton-现在只需设置其Container属性即可实现所需的样式:

decoration