Reputation: 217
I am doing a null check with the operator '??'.
Text(contact.rating.toString() ?? " ",
However the text shows null
when it is null, instead of
What's the best way to write this?
Upvotes: 0
Views: 807
Reputation: 2862
Because contact.rating
is null, so you have to do the following
Text(contact.rating?.toString() ?? " "),
Upvotes: 3
Reputation: 1341
Here's one way:
Text(contact.rating != null ? contact.rating.toString() : " ")
Upvotes: 0