How would you get this code to work:

// Can't assign an int to a String
String heightInCM = 185;
// Can't compare String to int
String heightCategory = heightInCM > 175 ? "Tall" : "Normal";

Change the “type” of heightInCM to var to infer an int, and this code will work.
Also, I believe it’s common in Dart to use single quotes for strings unless you have a good reason not to:

var heightInCm = 185;
var heightCategory = heightInCm > 175 ? 'Tall' : 'Normal';

Senior Software Developer. Hard-Core Learning Addict.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store