如何在提示文本中以及扑朔迷离中的dropdownbutton中具有不同的文本溢出样式?

发布于 2025-01-26 07:26:06 字数 1774 浏览 3 评论 0原文

我想将dropdownbutton的提示文本的溢出设置为省略号,但是当我打开下拉列表时,我想在下拉列表中显示整个选择,因此我将其设置为可见 但是,尽管我将其设置在省略号上,但会发生什么提示文本会获得“可见”的效果,该如何解决?

我想发生的事情:

”在此处输入图像描述”

发生了什么:

”在此处输入图像描述

这是代码

Expanded(
            child: DropdownButton(
              hint: Text(
                widget.choices[0],
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                  color: Colors.black,
                ),
              ),
              iconSize: 40,
              isExpanded: true,
              style: TextStyle(
                color: Colors.black,
              ),
              onChanged: changeValueFunction,
              items: widget.choices
                  .map(
                    (value) => DropdownMenuItem(
                      value: value,
                      child: Text(
                        value,
                        overflow: TextOverflow.visible,
                        style: TextStyle(
                        ),
                      ),
                    ),
                  )
                  .toList(),
            ),
          ),

I want to set the overflow of hint text of DropdownButton to ellipsis, but I want to show the whole choice in the DropdownMenuItem when I open the dropdown list, so I set it to visible
But what happens is that the hint text gets the "visible" effect despite that I set it to ellipsis, How can I fix this?

What I want to happen:

enter image description here
enter image description here

What happens:

enter image description here
enter image description here

Here is the code

Expanded(
            child: DropdownButton(
              hint: Text(
                widget.choices[0],
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                  color: Colors.black,
                ),
              ),
              iconSize: 40,
              isExpanded: true,
              style: TextStyle(
                color: Colors.black,
              ),
              onChanged: changeValueFunction,
              items: widget.choices
                  .map(
                    (value) => DropdownMenuItem(
                      value: value,
                      child: Text(
                        value,
                        overflow: TextOverflow.visible,
                        style: TextStyle(
                        ),
                      ),
                    ),
                  )
                  .toList(),
            ),
          ),

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

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

发布评论

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

评论(1

寻梦旅人 2025-02-02 07:26:06

使用

selectedItembuilder

绘制自定义项目的

use

selectedItemBuilder

to draw custom item

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