themeData.copyWith(
colorScheme: //...
scaffoldBackgroundColor: //...
textTheme: const TextTheme(
headline1: TextStyle(/*...*/),
subtitle1: TextStyle(/*...*/),
button: TextStyle(/*...*/),
bodyText1: TextStyle(/*...*/),
);
VS
class TextThemeConstatns {
const TextStyle headline1 = TextStyle(/*...*/);
const TextStyle subtitle1 = TextStyle(/*...*/);
const TextStyle button = TextStyle(/*...*/);
const TextStyle bodyText1 = TextStyle(/*...*/);
}
I'm aware that using TextTheme will give me some out-of-the-box styling for Material widgets (buttons, appbars, ect.) But I'm working on a project that, let's say, isn't following material design, so that point is almost irrelevant.
That's said, is there any advantage of defining my styles in TextTheme
rather that a simple constants file? Assuming that I can see many advantages for the latter that are out of the scoop of this question.
A similar frequently asked question is "ThemeData
vs constants file". Well for that, the ability to change the theme in any point of time is what cuts the deal in favor of ThemeData
. In my case, I don't see any case where text styles needs to be changed.
One point that could be relevant, is accessibility options or system defined font size preferences. Maybe using TextTheme
utilize the api in a way that makes my app more compatible with some of those cases? I didn't find anything about that.