简体   繁体   English

如何在 FLutter 上更改 ThemeData() 中的 ListTile 前导图标颜色

[英]How to change ListTile leading icon color in ThemeData() on FLutter

I have a list tile widget and the color of the leading icon is set to default for both light and dark theme in flutter.我有一个列表图块小部件,flutter 中浅色和深色主题的前导图标颜色都设置为默认值。

After upgrading flutter to Flutter 2.5.1, the list tile leading icon is weird in dark mode. flutter 升级到 Flutter 2.5.1 后,深色模式下列表磁贴图标异常。

I have to change the leading icon color to white in the dark mode and default in the light mode and this has to be changed in the Theme Data manually.我必须在深色模式下将前导图标颜色更改为白色,在浅色模式下更改为默认颜色,这必须在主题数据中手动更改。

在此处输入图像描述

My Theme class我的主题 class

  static ThemeData myTheme(bool isDark) {
    return !isDark
        ? ThemeData.light().copyWith(
            primaryColor: Colors.deepPurple,
            colorScheme: ColorScheme.fromSwatch().copyWith(
              secondary: Colors.deepPurple,
            ),
          )
        : ThemeData.dark().copyWith(
            primaryColor: Colors.deepPurple,
            colorScheme: ColorScheme.fromSwatch().copyWith(
              secondary: Colors.deepPurple,
            ),
          );
  }
}

           return MaterialApp(
              themeMode: ThemeMode.system,
              theme: ThemeData(
                iconTheme: IconThemeData(color: Colors.blue),
              ),
              darkTheme: ThemeData(
                iconTheme: IconThemeData(color: Colors.red),
              ));

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

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