简体   繁体   中英

how too style DropdownSearch Selected Item in flutter

I am using dropdown_search How to style Selected Item in the dropdown?? 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,

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

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