簡體   English   中英

Flutter 更改下拉箭頭顏色

[英]Flutter Change Dropdown arrow color

如何更改下拉箭頭顏色?

這是我想要的

在此處輸入圖片說明

這就是我得到的

在此處輸入圖片說明

我的小部件:

            DropdownButtonHideUnderline (
          child: DropdownButton<String>(
            isExpanded: true,
            value: dropdownValue,
            onChanged: (String newValue) {
              setState(() {
                dropdownValue = newValue;
              });
            },
            items: <String>['Bank Deposit', 'Mobile Payment', 'Cash Pickup']
                .map<DropdownMenuItem<String>>((String value) {
              return DropdownMenuItem<String>(
                value: value,
                child: Text(value),
              );
            })
                .toList(),
          ),
        ),

我嘗試用主題包裝並更改亮度,但它僅將箭頭從白色更改為黑色。 我想用其他顏色。

這可以通過icon:屬性在DropdownButton

DropdownButtonHideUnderline(
            child: DropdownButton<String>(
              isExpanded: true,
              value: dropdownValue,
              onChanged: (String newValue) {
                setState(() {
                  dropdownValue = newValue;
                });
              },
              hint: Text('Select'),
              icon: Icon(                // Add this
                Icons.arrow_drop_down,  // Add this
                color: Colors.blue,   // Add this
              ),
              items: <String>['Bank Deposit', 'Mobile Payment', 'Cash Pickup']
                  .map<DropdownMenuItem<String>>((String value) {
                return DropdownMenuItem<String>(
                  value: value,
                  child: Text(value),
                );
              }).toList(),
            ),
          ),

感謝@anmol.majhail,無論如何使用iconEnabledColor屬性發現了一些更簡單的東西。

               DropdownButtonHideUnderline (
          child: DropdownButton<String>(

            iconEnabledColor: Colors.indigo, // game changer

            isExpanded: true,
            value: dropdownValue,
            onChanged: (String newValue) {
              setState(() {
                dropdownValue = newValue;
              });
            },
            items: <String>['Bank Deposit', 'Mobile Payment', 'Cash Pickup']
                .map<DropdownMenuItem<String>>((String value) {
              return DropdownMenuItem<String>(
                value: value,
                child: Text(value),
              );
            })
                .toList(),
          ),
        ),

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM