简体   繁体   中英

How to change the background color in DropDownButton?

I watched the official DropDownButton example and the background is always gray when pressed for a long time, how can I change it?

在此处输入图像描述

When the DropdownButton is on focused, it uses focusColor . For the long press it uses the splashColor . Yo can wrap with Theme and provide splashColor.

Theme(
  data: ThemeData(
    splashColor: Colors.green,
  ),
  child: DropdownButton<String>(
    dropdownColor: Colors.pink, // main bg 
    focusColor: Colors.amber,// when focused
    value: dropdownValue,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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