简体   繁体   English

DropdownSearch Flutter - 字体太大

[英]DropdownSearch Flutter - Font too big

I have the following code for the dropdownSearch in Flutter However the font is fixed and not changing when I change screen size我在 Flutter 中有以下 dropdownSearch 代码但是字体是固定的,当我更改屏幕大小时不会改变

enter image description here在此处输入图像描述

DropdownSearch<String>(
        items: items,
        showSearchBox: showSearchBox ?? false,
        dropdownSearchDecoration: InputDecoration(
          contentPadding: const EdgeInsets.only(right: 8.0, left: 8.0),
          floatingLabelStyle:
              kResponsiveTextUbuntuFont(context, kDarkGreyColor),
          labelText: labelTxt,
          labelStyle: kResponsiveTextUbuntuFont(context, kDarkGreyColor),
          focusedBorder: const OutlineInputBorder(
            borderSide: BorderSide(color: kDarkGreyColor, width: 2),
          ),
          border: const OutlineInputBorder(
            borderSide: BorderSide(color: kDarkGreyColor, width: 2),
          ),
        ),
        onChanged: (newItem) => {},
        showSelectedItems: true,
        selectedItem: selectedItem,
        popupBackgroundColor: kBackgroundColor,
        dropdownSearchBaseStyle:
            kResponsiveTextUbuntuFont(context, kDarkGreyColor),
        mode: Mode.MENU,
      ),

Font:字体:

TextStyle KResponsiveTitleUbuntuFont(BuildContext context, Color color) {
  return TextStyle(
      fontFamily: 'Ubuntu',
      fontSize:
          (setWidth(context, 0.001) >= 1) ? 30 * setWidth(context, 0.001) : 50,
      fontWeight: FontWeight.w100,
      wordSpacing: 5,
      color: color);
}

I always find the solution directly after asking my own question xD... Here's the solution:我总是在问自己的问题后直接找到解决方案 xD ......这是解决方案:

  Widget _customDropDownText(BuildContext context, String? name) {
    return Container(
      child: Text(
        name.toString(),
        style: kResponsiveTextUbuntuFont(context, kDarkGreyColor),
      ),
    );
  }

Build:建造:

@override
  Widget build(BuildContext context) {
.
.
.
DropdownSearch<String>(
        items: widget.items,
        dropdownBuilder: _customDropDownText,
        showSearchBox: widget.showSearchBox ?? false,
.
.
.
}

solution解决方案

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

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