Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can someone explain what does the colon do in this case? and the overall definition of this code/

Hi I’m learning Flutter and I came across this line of code which looks like this.

width: _width < 1000 ? _width / 1.2 : 833,
height: _width < 1000 ? _width / 2 : 500,

Can someone please explain what does the colon mean in this case?
Or just the overall meaning is fine.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It’s a ternary operator, basically shorthand for if-then-else

i.e. "if _width is less than 1,000 return width divided by 1.2 else return 833"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading