Reputation: 7156
How can I use if-else construction in build method?
Now I use double if
:
if (_rapport.isNotEmpty && _rapport.length == 3)
Container(
child: Text(_rapport),
),
if (_rapport.isEmpty || _rapport.length != 3)
const Text('wrong input'),
while using else
brings the error:
Upvotes: 0
Views: 176
Reputation: 100
You can use a ternary if-statement.
condition
? true
: false;
With context:
5 > 1
? print("this will be printed")
: print("this won't be printed");
https://medium.com/run-dart/dart-dartlang-introduction-if-else-conditional-statement-1350a56e2e98?
Upvotes: 2