You can't access other instance members styleColor
from the initializer of another. To solve this, you need to delay the initialization of header
in some way, which could be accomplished by using the initializer list or making header
a getter.
Using initializer list:
class Style {
Color styleColor;
Style(this.styleColor) :
header = TextStyle(
color: styleColor,
fontSize: 24,
fontFamily: "Poppins",
fontWeight: FontWeight.w700,
),
title1 = TextStyle(
color: styleColor,
fontSize: 24,
fontFamily: "Poppins",
fontWeight: FontWeight.w700,
);
final TextStyle header;
final TextStyle title1;
}
Making header
a getter:
class Style {
Color styleColor;
Style(this.styleColor);
TextStyle get header => TextStyle(
color: styleColor,
fontSize: 24,
fontFamily: "Poppins",
fontWeight: FontWeight.w700,
);
TextStyle get title1 => TextStyle(
color: styleColor,
fontSize: 24,
fontFamily: "Poppins",
fontWeight: FontWeight.w700,
);
}