I want that every Text
inside a particular Widget
will have a white color, although they all can have different sizes. I know I can change every singe Text
to have a white color, but I want to make it smart and change the Theme for that particular Widget
.
I tried this:
DefaultTextStyle.merge(
style: TextStyle(color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('Text 1',
style: Theme.of(context).textTheme.title,
),
Text('Text 2')
],
),
),
The problem is Text 1
becomes black and Text 2
is white as I wanted.
I thought that using DefaultTextStyle.merge
I would still be able to use Theme.of(context)
to get the general TextTheme
, still maintaining the changes over DefaultTextStyle
but apparently I am wrong.
What's the correct way of changing a sub-tree's text color, while being able to access the rest of the original Theme
?