Search code examples
flutterdartmaterial-designcolor-scheme

I want to change the color of ``` titleTextStyle: Theme.of(context).textTheme.titleLarge```


I want to set the text style using titleTextStyle: Theme.of(context).textTheme.titleLarge, in my app bar but i need to change de color and i don't now how to do it.


Solution

  • Basically you stack the Theme.of(context) and copyWith methods, each time making one change. This can get pretty verbose if you have a lot of things to change. For example, to make a titleLarge with error color

    Text(
        'ERROR',
             style: Theme.of(context).textTheme.titleLarge?.copyWith(
             color: Theme.of(context).colorScheme.error),
        )