flutter inline if statement code example
Example 1: conditionalstatement in widget flutter
Container(
color: Colors.white,
child: ('condition')
? Widget1(...)
: Widget2(...)
)
Example 2: flutter conditional statement
condition? Text("True"): null,
Example 3: dart terbary
int minVal = (a < b) ? a : b; // if(a < b) {minVal = a;} else {minVal = b;}
var x = y ?? z; // assign y to x if y is not null, else z
var x ??= y; // assign y to x only if x is null
myObject?.myProp // (myObject != null) ? myObject.myProp : null
myObject?.myProp?.someMethod() // chainable