Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I have checked for null value but still get error saying I didn't checked

enter image description here I already have a null check before using the value but it still give me errorenter image description here

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can put an ! behind it to indicate you are sure it can’t be null, so like

for (final value in widget.details.data.productPriceObjs!) {

If you don’t like using ! you can alternatively write

var objects = widget.details.data.productPriceObjs;
if (objects != null) {
  for (final value in objects) {
  
  }
}

Somehow the compiler is fine with it when there isn’t "nesting" in the check

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading