下拉搜索颤音 - 字体太大

发布于 2025-02-11 16:55:16 字数 1502 浏览 1 评论 0原文

我有以下flutter中的下拉搜索的代码 字体已固定并且不会更改

但是,当我更改屏幕大小输入图像描述时,

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,
      ),

。字体:

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 have the following code for the dropdownSearch in Flutter
However, the font is fixed and does not change when I change the screen size

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);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时间你老了 2025-02-18 16:55:16

在问自己的问题XD之后,我总是直接找到解决方案...
这是解决方案:

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

构建:

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

解决方案

I always find the solution directly after asking my own question xD...
Here's the solution:

  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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文