Reputation:
In the turnary operator statement 5 == 5 ? print('Correct') : print('Wrong')
, I want the statement to return nothing(You can see it's returning a print statement) if the evaluation of the initial expression turns false, how do I do that?
The actual code is given below, the return type cannot be null. So, that isn't an option
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text(times[index]),
newMessagehasCome ? Icon(Icons.laptop) ?
],
)
Upvotes: 0
Views: 63
Reputation: 31289
You can do it like this if you project supports Dart 2.3.0 or later:
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text(times[index]),
if (newMessagehasCome)
Icon(Icons.laptop)
],
)
Upvotes: 1