I’m wondering if using style files with methods like these makes sense:
static TextStyle defaultStyle() {
return const TextStyle(
fontFamily: 'Ubuntu',
letterSpacing: 0,
);
}
static TextStyle display1() {
return defaultStyle().copyWith(
color: AppColors.black900,
fontSize: 57.0,
fontWeight: FontWeight.w900,
);
}
We keep these values in one place, but when using them, we can’t use const before the widgets.
Result:
Text(
'Hello',
textAlign: TextAlign.center,
style: AppTextStyles.display1().copyWith(color: AppColors.gray500),
),
Instead of:
const Text(
'Hello',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Ubuntu',
letterSpacing: 0,
color: AppColors.black900,
fontSize: 57.0,
fontWeight: FontWeight.w900,
),
),
I’ve noticed this in every project I’ve watched so far. Isn’t this a mistake that affects the performance of the application?