Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart Flutter : How to use multiple statements in ternary inside a flutter widget [closed]

Tags:

flutter

dart

Is it possible to write such a line, and within this line I want change a variable value?

opacity: condition == true ? 1, stringName ='Steve' : 0
like image 832
Ant D Avatar asked Dec 03 '22 20:12

Ant D


2 Answers

Not sure what you expect the code to do exactly but my guess

opacity: condition == true ? (){ stringName = 'Steve'; return 0; }() : 0;

You can't have a list of expressions in the true or false part, only one single expression.

like image 133
Günter Zöchbauer Avatar answered Feb 07 '23 06:02

Günter Zöchbauer


I think this is what you wanted

opacity : condition== true ? 1 : stringName == "Steve" ? 0 : 2,
like image 28
Technical Radar Avatar answered Feb 07 '23 05:02

Technical Radar