- 新增 DetailItemScreen 组件,用于展示物品详细信息 - 在 ItemListScreen 中添加物品列表项的点击事件,跳转到物品详情页面- 修改 Item 模型,将 isInUse 字段类型从 String改为 String? - 更新数据库表结构,将 is_in_use 列类型从 INTEGER 改为 TEXT
56 lines
1.2 KiB
Dart
56 lines
1.2 KiB
Dart
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<String, dynamic> toMap() {
|
|
return {
|
|
'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<String, dynamic> 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'],
|
|
);
|
|
}
|
|
} |