flutter - 禁用时如何更改下拉默认文本颜色?

当下拉菜单被禁用时,它具有默认的黑色文本颜色,我想更改它。有更改图标颜色的选项,但没有更改文本颜色的选项。
任何帮助将不胜感激。

DropdownButtonFormField(
        value: widget.selectedValue,
        items: widget.dropdownItems,
        dropdownColor: customTheme.colors.black30,
        iconEnabledColor: customTheme.colors.textColor,
        iconDisabledColor: Color.fromARGB(143, 144, 144, 144),

最佳答案

更改应用主题的属性 disabledColor 或使用 Theme 小部件:

Theme(
        data: Theme.of(context).copyWith(disabledColor: customTheme.colors.black30),
        child: DropdownButtonFormField(
            value: widget.selectedValue,
            items: widget.dropdownItems,
            dropdownColor: customTheme.colors.black30,
            iconEnabledColor: customTheme.colors.textColor,
            iconDisabledColor: Color.fromARGB(143, 144, 144, 144),
        ),
),

https://stackoverflow.com/questions/72050800/

相关文章:

windows - 为什么没有启动 Windows 应用程序

hibernate - 我在 grails 中遇到完整性违规异常。如何级联删除到grails中的相关

javascript - NextJS - 在 getStaticProps 中获取动态变量

visual-studio - 如何从VS2022状态栏中删除 "Add to Source Con

android - 提供的相机选择器无法为给定用例解析相机

swift - 解决包依赖 swiftUI 项目时出错

vue.js - 在 pinia 中存储 react (ref) 值

flutter - 从 2.8.1 升级到 Flutter 3.0,得到 : Warning: Op

html - 如何用div和css创建一个圆弧的边?

reactjs - 如何让 Next Image 组件与 Storybook 一起工作