class Item { int? id; // 名称 final String name; // 分类 final int? categoryId; // 位置 final int? locationId; // 描述 final String? description; // 购买日期 final DateTime? purchaseDate; // 是否使用 final bool isInUse; final DateTime? createdAt; final DateTime? updatedAt; Item({ this.id, required this.name, this.categoryId, this.locationId, this.description, this.purchaseDate, this.isInUse = false, this.createdAt, this.updatedAt, }); Map toMap() { return { 'id': id, 'name': name, 'categoryId': categoryId, 'locationId': locationId, 'description': description, 'purchaseDate': purchaseDate, 'isInUse': isInUse, 'createdAt': createdAt, 'updatedAt': updatedAt, }; } factory Item.fromMap(Map map) { return Item( id: map['id'], name: map['name'], categoryId: map['categoryId'], locationId: map['locationId'], description: map['description'], purchaseDate: map['purchaseDate'], isInUse: map['isInUse'], createdAt: map['createdAt'], updatedAt: map['updatedAt'], ); } }