Json parsing failure in message.dart company.dart job.dart List<dynamic > cannot to List<message >
ZukGit opened this issue · 3 comments
When I git clone this project , I find that it cause a RuntimeException , and message company job Page is Empty !
I find that I change method fromJson(String json)
from :
static List fromJson(String json) {
return JSON
.decode(json)['list']
.map((obj) => Job.fromMap(obj))
.toList();
}
to:
static List fromJson(String json) {
List _jobs = [];
for (var value in new JsonDecoder().convert(json)['list']) {
_jobs.add(Job.fromMap(value));
}
return _jobs;
}
and make method buildJobItem return Widget , The Project work well .
return JSON
.decode(json)['list']
.map((obj) => Job.fromMap(obj))
.toList();
}
map后面指定类型就OK了
When I git clone this project , I find that it cause a RuntimeException , and message company job Page is Empty ! how can I to resolve it.
static List fromJson(String json) {
return JSON
.decode(json)['list']
.map((obj) => Job.fromMap(obj))
.toList();
}
static List fromJson(String json) json => str
JSON => json