Change color locally according to brightness mode

Issue

Is it possible to change the color from a specific icon locally, without using theme? something like

color: Brightness.light == "something" ? Colors.red : Colors.green

Solution

You can get current theme mode from Theme.of(context).brightness.

color: Theme.of(context).brightness == Brightness.dark
    ? Colors.white
    : Colors.black,

Answered By – Yeasin Sheikh

Answer Checked By – Clifford M. (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *