40 lines
765 B
Dart
40 lines
765 B
Dart
class Category {
|
|
final int? id;
|
|
final String name;
|
|
final String type; // 'income' or 'expense'
|
|
final String icon;
|
|
final int color;
|
|
final int? parentId; // 支持多级分类
|
|
|
|
Category({
|
|
this.id,
|
|
required this.name,
|
|
required this.type,
|
|
required this.icon,
|
|
required this.color,
|
|
this.parentId,
|
|
});
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'id': id,
|
|
'name': name,
|
|
'type': type,
|
|
'icon': icon,
|
|
'color': color,
|
|
'parentId': parentId,
|
|
};
|
|
}
|
|
|
|
factory Category.fromMap(Map<String, dynamic> map) {
|
|
return Category(
|
|
id: map['id'],
|
|
name: map['name'],
|
|
type: map['type'],
|
|
icon: map['icon'],
|
|
color: map['color'],
|
|
parentId: map['parentId'],
|
|
);
|
|
}
|
|
}
|