I have a TextStyle and a variable textBold that can be true or false. How to implement if in this TextStyle?
TextStyle(
color: Colors.white,
if ($textBold == true){
fontWeight: FontWeight.bold,
}
Use conditional statement like below.
Text(
"Hello",
style: TextStyle(
fontWeight: textBold ? FontWeight.bold : FontWeight.normal
),
),