I already have a null check before using the value but it still give me error
CodePudding user response:
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
CodePudding user response:
Put !
mark behind widget.details.data.productPriceObjs
to make sure to compiler that this value is not null
For more details about null safety read here