class CardInfo { //Constructor String id; String description; String role; int score; CardInfo.fromJson(Map json) { this.id = json['id']; this.description = json['description']; this.role = json['Role']; this.score = json['score']; }}var ci = new CardInfo.fromJson(myJson);您可以使用源生成工具,例如 https://github.com/dart-
lang/source_gen
https://pub.dartlang.org/packages/json_serializable为您生成序列化和反序列化代码。
如果您更喜欢使用不可变的类,那么https://pub.dartlang.org/packages/built_value是一个不错的选择。



