How to include if statement in dart's TextStyle
1,216
Use conditional statement like below.
Text(
"Hello",
style: TextStyle(
fontWeight: textBold ? FontWeight.bold : FontWeight.normal
),
),
Author by
DaleRoyFall
Updated on December 01, 2022Comments
-
DaleRoyFall over 1 year
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, }
-
DaleRoyFall over 4 yearsThanks, I completely forgot about this if's form
-
DaleRoyFall over 4 yearsI understand that i could do something like that in children, but in style i couldn't
-
Farmaan Elahi over 4 yearsThat isn't supported as of now in Dart