class Book {
final int? id;
final String title;
final String author;
Book({
this.id,
required this.title,
required this.author,
});
factory Book.fromJson(Map<String, dynamic> json) {
return Book(
id: json['id'] ?? "",
title: json['title'] ?? "",
author: json['author'] ?? "",
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'title': title,
'author': author,
};
}
}
我得到这个错误类型'图书'不是类型'Map〈字符串,动态〉'在类型转换的子类型我已经提到了下面的代码,你能帮我纠正错误.
1条答案
按热度按时间bihw5rsg1#
使用此类型的Model类