ternary operator dart code example
Example 1: dart ternary operator
If you're referring to else if statements in dart, then this ternary operator:
(foo==1)? something1():(foo==2)? something2():(foo==3)? something3(): something4();
is equivalent to this:
if(foo == 1){
something1();
}
elseif(foo == 2){
something2();
}
elseif(foo == 3){
something3();
}
else something4();
Example 2: dart terbary
int minVal = (a < b) ? a : b;
var x = y ?? z;
var x ??= y;
myObject?.myProp
myObject?.myProp?.someMethod()