Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to change flutter text color for dark and light theme?

How to change flutter text color for dark theme and light theme, can anyone answer me ?

title:  Text('Kitchen Name', )

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

There are two ways of doing so:

  1. You can set both a theme and a darkTheme variance in your MaterialApp properties and having it automatically changed whenever the OS theme changes, based on the text properties that you set;
  2. Or, you can manually check for the current brightness in your Text style’s property (when the brightness is dark, the OS should be using a dark theme, and a light when it’s light).
title: Text(
          'Kitchen Name',
          style: Theme.of(context).brightness == Brightness.dark ? TextStyle(color: Colors.white) : TextStyle(color: Colors.black),
        ),

I’d pick the 1 since it’s the most correct way of doing it.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading