'type 'Null' is not a subtype of type 'String' while receiving json data in flutter
I am receiving photos as - "photos":[null], in my json data. (It is a list of string of urls).
And in my model class, I am receiving my data as -
photos: List<String>.from(
json["photos"].map(
(x) => x,
),
),
And in my class, I tried to declare photos variable like this -
List<String?>? photos;
How should I correct this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
