[Solved] How to apply secondaryColor?

Question

Asked by rozerro on November 16, 2021 (source).

We can define secondaryColor in ThemeData like this:

theme: ThemeData(
          primaryColor: Colors.black,
          colorScheme: ColorScheme.fromSwatch().copyWith(
            secondary: Colors.pinkAccent,
          ),

How to apply it in the following snippet?

ListTile(
    trailing: Icon(
        Icons.edit,
        color: ... , // secondary color here
    ),

Answer

Question answered by Jahidul I (source).

Try with this

color: Theme.of(context).colorScheme.secondary
FLUTTER
SHARE: