0

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?

2 Answers 2

3

Because contact.rating is null, so you have to do the following

Text(contact.rating?.toString() ?? " "),

Sign up to request clarification or add additional context in comments.

Comments

0

Here's one way:

Text(contact.rating != null ? contact.rating.toString() : " ")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.