0

I am struggling to figure out an issue with a null check operator. For one, my code is the exact same in another area of my program and I am getting data just fine from it. I have gone over it and over it for the last two weeks and have found nothing that helps. As shown in my screen shots, I am actually seeing the data come in from my API call and the field that it is calling null, is not actually null. Please help as this is extremely frustrating.

enter image description here

enter image description here

Perhaps we can jump in a chat session and I can share more of my code specifics based on questions one would have in helping me resolve this issue.

Thanks!

1 Answer 1

1

You are getting null value on controller.port, better check null and then render the image like

if(controller.port?.imageUrl!=null)  
    Image.network(controller.port!.imageUrl)

More about understanding-null-safety

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

2 Comments

I don't understand why I am getting a null value though. In my response from the API, the image_url: does have a value. Regardless, having a check would be wise because in the event a new port is created, it wont have a value until the customer assigns one. Even still will this check pass since the API is delivering a value in the key:value pair?
You can check few cases like, making sure it is getting data using async method then setState. Others things can happen, try break point on this controller on debug mode

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.