简体   繁体   中英

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.

After upgrading flutter to Flutter 2.5.1, the list tile leading icon is weird in dark mode.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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