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,
}
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
),
),
You cannot do that on a constructor at that level. If it only possible when the parameter except at Map or List.
Example for List:
Column(
children: <Widget>[
if(Your Condition)
YourWidget()
],
)
Example for Map:
final x = {"id":1};
final y = {
if(Your Condition)
"SomeKey":"Some Value",
}