Reputation: 3774
I see this error message which says two things -
For the first error I have added a null check to the code which also doesn't fix issue and for the second one I have no idea what to do with it.
Upvotes: 0
Views: 323
Reputation: 4089
The second error is essentially saying that you can't fix the error only by adding a null check. As you already know, the compiler treats local variable declarations as non-nullable within contexts where it can be inferred that the variable is not null - that type conversion is called "promotion".
The compiler cannot perform promotion on instance properties, however - So even though you've already checked the value, you still need to add a !
on the end to unwrap the value.
if (response.data != null) {
Map<String, dynamic> data = jsonDecode(response.data!);
// Snip
}
Upvotes: 1