我已经宣布了自己的论点,但对我来说说3 pos。预期参数,但找到0。错误发生于 Article.fromJSON 部分。有人知道为什么吗?
class Article {
final String id;
final String caption;
final DateTime timestamp;
Article(this.id, this.caption, this.timestamp, );
factory Article.fromJSON(Map<String, dynamic> jsonMap) {
return Article(
id: jsonMap['id'] as String,
caption: jsonMap['caption'] as String ,
timestamp: jsonMap['timestamp'] as DateTime ,
);
}
Map toMap() {
var map = new Map<String, dynamic>();
map["id"] = id;
map["caption"] = caption ;
map["timestamp"] = timestamp ;
return map;
}
}
答案 0 :(得分:0)
这是因为您的参数未命名
更改
Article(this.id,this.caption,this.timestamp,);
收件人
Article({this.id,this.caption,this.timestamp,});