简体   繁体   English

如何删除 flutter 中的可搜索下拉默认填充?

[英]How to remove searchable dropdown default padding in flutter?

Hello this is my flutter widget SearchableDropdown, and it is wrapped using a container just for highlighting the border for understanding how much space the widget have been taken.您好,这是我的 flutter小部件SearchableDropdown,它使用容器包装,仅用于突出显示边框以了解小部件占用了多少空间。 I want to reduce the padding/space of the SearchableDropdown widget around the text, and make the UI like this.我想减少文本周围 SearchableDropdown 小部件的填充/空间,并使 UI像这样。 How to do that?怎么做?

new Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    new Text(
                      'You are here',
                      style: GoogleFonts.poppins(
                          color: HexColor("#B8B8B8"), fontSize: 10),
                      textAlign: TextAlign.start,
                    ),
                    new Container(
                      decoration: new BoxDecoration(
                        border: Border.all(color: Colors.red),
                      ),
                      child: _searchableDropDown(context, providerData),
                    )
                  ],
                ),



 Widget _searchableDropDown(BuildContext context, HomePageProviderData data) {
  return new SearchableDropdown.single(
    hint: new Text(
      data.currentCity,
      style: GoogleFonts.poppins(
        textStyle: TextStyle(
            color: Color(0xFF373539),
            fontSize: 16,
            fontWeight: FontWeight.w600),
      ),
    ),
    underline: SizedBox(),
    displayClearIcon: false,
    items: data.listCity.map((item) {
    //
    }).toList(),
    onChanged: (String value) {
      //
    },
  );
}

try use wrapping your dropdown inside SizedBox() like this:尝试使用将下拉列表包装在SizedBox()中,如下所示:

SizedBox(
  height: 20,
  child: _searchableDropDown(context, providerData),
);

result:结果:

结果

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

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