简体   繁体   English

如何在flutter中设置DropdownSearch Selected Item的样式

[英]how too style DropdownSearch Selected Item in flutter

I am using dropdown_search How to style Selected Item in the dropdown??我正在使用dropdown_search如何在下拉列表中设置所选项目的样式? I am trying searching the best way but am not able to do that, please suggest me some ways.我正在尝试寻找最好的方法,但无法做到这一点,请给我一些建议。

  DropdownSearch(
            favoriteItemsAlignment: MainAxisAlignment.center,
            autoValidateMode: AutovalidateMode.always,
            mode: modes,
            showSearchBox: true,
            maxHeight: maxHeight,
            popupItemBuilder: dropdownItemSuggestion,
            dropdownSearchDecoration: InputDecoration(
              disabledBorder: InputBorder.none,errorText: errormsg,
              hintText: dropdownHintText,
              hintStyle: UtilsMethods.mediumTextStyle(AppColor.grey, 14),
            ),
            items: dropdownItem,
            onChanged: dropdownOnChanged,
            selectedItem: dropdownSelectedItem ,       ///I want to style this text
    
    
          ),

You can use dropdownBuilder to decorate the selected item,您可以使用dropdownBuilder来装饰所选项目,

DropdownSearch<String>(
  dropdownBuilder: (context, selectedItem) {
    return Text(
      selectedItem ?? "",
      style: TextStyle(
        color: Colors.green,
      ),
    );
  },
  popupProps: PopupProps.menu(
    showSelectedItems: true,
    disabledItemFn: (String s) => s.startsWith('I'),
  ),
  items: ["Brazil", "Italia (Disabled)", "Tunisia", 'Canada'],
  selectedItem: "Brazil",
)

More about dropdown_search更多关于dropdown_search

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

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