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