Reputation: 9
i wanna use custom textTheme inside the ThemeData but this custom text will not be apply to all Text widget for instance : Text inside the ListTile will get style from inherit Widget which is not what i wanna , and also i don't wannt to restyle my ListTile but how to make the custom textTheme apply all the Text inside the app without any calling Theme.of(context).textTheme.bodyMedium,
textTheme: const TextTheme(
bodyMedium: TextStyle(fontSize: 14.0, color: Colors.red),
),
in below example
Column(
children: [
ListTile(
trailing: Icon(Icons.more_vert),
title: const Text('You have pushed the button this many times:'),
),
const Text('You have pushed the button this many times:'),
Icon(Icons.more_vert),
],
),
in this code only the plain text will get the red color but inside the ListTile i have to call the Theme.of(context).textTheme.bodyMedium, property to ListTile get the effect from the textTheme is there any solution to implement effect to entire Text in the app ?? i don't want to call theme property and i don't wanna use DefaultTextStyle
Upvotes: 0
Views: 38
Reputation: 101
TextTheme cannot apply to all text widget cause text widget need a text style while textTheme contains multiple text style.
To change text style for all text in little, use listTileTheme. Use DefaultTextStyle widget to change the style of all defendant Text widget.
This tread throws more light on it.
Upvotes: 0
Reputation: 166
ListTile
's title text uses TextTheme.bodyLarge
or TextTheme.titleMedium
by default. But you only customized TextTheme.bodyMedium
. To customize all the Texts in the app, you should set all the properties in TextTheme
.
You can find the default text style for ListTile
here.
ListTile.titleTextStyle
ListTile.subtitleTextStyle
Upvotes: 1