更改 ExpansionTile 中的尾随图标颜色

Tar*_*iAg 8 flutter flutter-design

keyboard_down_arrow我需要更改尾随的颜色ExpansionTile。我尝试将它包装在主题小部件中并设置重音、主要和图标主题,但似乎没有任何效果。

Theme(
                  data: Theme.of(context).copyWith(
                    dividerColor: Colors.transparent,
                    accentColor: Colors.black,
                  ),
                  child: ExpansionTile(
                    //
                    title: Text("Some Text"
                    ),
                    childrenPadding: EdgeInsets.symmetric(horizontal: 15),
                    children: [
                      
                    ],
                  ),
                ),
Run Code Online (Sandbox Code Playgroud)

小智 17

我有具有打开/关闭状态的最新解决方案:

Theme(
    data: Theme.of(context).copyWith(
      unselectedWidgetColor: Colors.white, // here for close state
      colorScheme: ColorScheme.light(
          primary: Colors.white,
      ), // here for open state in replacement of deprecated accentColor
      dividerColor: Colors.transparent, // if you want to remove the border
    ),
    child: ExpansionTile(
        ...
    ),
),...
Run Code Online (Sandbox Code Playgroud)


MRa*_*iaz 6

要更改尾随图标颜色,您可以使用扩展图块中的以下参数

 trailing: Icon(
              Icons.keyboard_arrow_down,
              color: Colors.green,
            ),
Run Code Online (Sandbox Code Playgroud)

例子:

 ExpansionTile(
                //
                title: Text("Some Text"),
                trailing: Icon(
                  Icons.keyboard_arrow_down,
                  color: Colors.green,
                ),
              ),
Run Code Online (Sandbox Code Playgroud)

以及主题颜色的使用color: Theme.of(context).primaryColor,

  • 这将使箭头图标静态并且不再旋转。 (9认同)

Tar*_*iAg 5

我找到了上述问题的解决方案。

在 flutter 的 Theme 类中将属性设置unselectedWidgetColor为您想要的颜色。