How to do if/else
on a line in Dart / Flutter ?
Type: variavel ? null : function() : function2()
How to do if/else
on a line in Dart / Flutter ?
Type: variavel ? null : function() : function2()
You can do this:
Comparison ?
Value if true :
Value if false ;
Ex:
void main() {
for (int i = 0; i < 5; i++) {
var result = i % 2 == 0 ? print("$i - par") : print("$i - impar");
}
}