Home > Software engineering >  Change color locally according to brightness mode
Change color locally according to brightness mode

Time:03-21

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

CodePudding user response:

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

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