如何自定义DropDownButton的外观?
我想做几件事,使下拉看起来像一个文本输入:
1.删除黄色框内的底线
1.缩进“使用电子邮件”,使其与“电子邮件地址”左对齐
1.使下拉框与文本框大小相同(默认大小)
1.将向下箭头放在下拉菜单右侧附近
1.添加边框
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.yellow[600],
borderRadius: BorderRadius.circular(4),
),
child: DropdownButton(
value: DropDownValue,
icon: const Icon(Icons.keyboard_arrow_down),
items: DropDownItems.map((String DropDownItems) {
return DropdownMenuItem(
value: DropDownItems,
child: Text(DropDownItems),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
DropDownValue = newValue!;
if (DropDownValue == 'Use Email') {
RegisterType = 'Email';
} else {
RegisterType = 'Mobile';
}
});
},
),
),
SizedBox(height: 10),
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(), labelText: RegisterType),
controller: _EmailAddressController,
),
1条答案
按热度按时间ddrv8njm1#
请尝试以下代码: