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 toMap() { return { 'id': id, 'name': name, 'type': type, 'icon': icon, 'color': color, 'parentId': parentId, }; } factory Category.fromMap(Map map) { return Category( id: map['id'], name: map['name'], type: map['type'], icon: map['icon'], color: map['color'], parentId: map['parentId'], ); } }