繁体   English   中英

在 flutter 中点击 DropdownButton 时如何更改启动颜色?

[英]How to Change the splash color when tapping DropdownButton In flutter?

在 flutter 的DropdownButton小部件中,我想在点击时更改启动颜色。 虽然我改变了DropdownButtonfocusColor但没有任何改变......如何做到这一点???

Container(
              height: 20,
              padding: EdgeInsets.only(
                right: 10,
                left: 10,
              ),
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(38),
                  border: Border.all(
                    color: Color(0xFFEAD6EE),
                  )),
              child: DropdownButton(
                focusColor: Color(0xFFC88FFF),
                style: TextStyle(
                  fontSize: 16,
                  color: fontColor.withOpacity(0.5),
                  fontWeight: FontWeight.normal,
                ),
                isExpanded: true,
                hint: Text('$editedCountry'),
                items: dropdownMenuItemByCategory('Country'),
                onChanged: (editedIndValue) {
                  _onCountrySelected(editedIndValue);
                },
                value: editedCountryID,
                underline: SizedBox(),
              ),
            ),

在此处输入图像描述

Theme包装你的DropdownButton

Theme(
    data: ThemeData(
      splashColor: Colors.red, //change based your need
    ),
    child: DropdownButton(

暂无
暂无

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

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