import 'package:json_annotation/json_annotation.dart'; part 'ProductInfo.g.dart'; @JsonSerializable() class ProductInfo { ProductInfo(this.id, this.productName, this.money, this.typeFlag,this.canUse); int id; String productName;//名称 int money;//钱 int typeFlag;//类型 bool canUse;//可用 factory ProductInfo.fromJson(Map json) => _$ProductInfoFromJson(json); Map toJson() => _$ProductInfoToJson(this); // 命名构造函数 ProductInfo.empty(); @override String toString() { return _$ProductInfoToJson(this).toString(); } }