简体   繁体   English

flutter中DropDownSearch去除边框的方法

[英]How to remove border from DropDownSearch in flutter

I am using drop down search to fetch and display the list of items from firebase but I am getting a form field box by default with this widget.我正在使用下拉搜索来获取和显示来自 firebase 的项目列表,但默认情况下我会使用此小部件获得一个表单字段框。 I wan't to remove this as it is not matching with my UI can anyone help me in this.我不想删除它,因为它与我的用户界面不匹配,任何人都可以帮助我。

Widget I used is https://pub.dev/packages/dropdown_search我使用的小部件是https://pub.dev/packages/dropdown_search

I am talking about the box that appears in this.我说的是这里出现的方框。 在此处输入图像描述

If you suggest me to use another widget then please also tell how to enable search oprtion in the same如果您建议我使用另一个小部件,那么还请告诉我如何在同一个小部件中启用搜索选项

If you want to remove border around dropdown element, set dropdownSearchDecoration to InputDecoration(border: InputBorder.none) :如果要删除下拉元素周围的边框,请将dropdownSearchDecoration设置为InputDecoration(border: InputBorder.none)

              DropdownSearch<String>(
                dropdownSearchDecoration: InputDecoration(border: InputBorder.none),
                // ...
              )
dropdownDecoratorProps: DropDownDecoratorProps(
                          dropdownSearchDecoration: InputDecoration(border: InputBorder.none),
                          
                          ),

The DropdownSearch widget border have its default input border style. DropdownSearch 小部件边框具有其默认的输入边框样式。 To remove, we need to overwrite it with our own inputBorder by setting the border to InputBorder.none .要删除,我们需要通过将边框设置为InputBorder.none来用我们自己的inputBorder覆盖它。

Code代码

DropdownSearch<String>(
  enabled: true,
  items: yourList,
  dropdownDecoratorProps: const DropDownDecoratorProps(
      dropdownSearchDecoration: InputDecoration(border:InputBorder.none),
              ),
  onChanged: (myVal) {},
  selectedItem: yourOwnSetValue
)

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

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