25 lines
642 B
Dart
25 lines
642 B
Dart
/// 分类(type: 1=支出,2=收入)
|
|
class Category {
|
|
final int id;
|
|
final String name;
|
|
final String icon; // emoji
|
|
final int type;
|
|
final int? sortOrder;
|
|
|
|
const Category({
|
|
required this.id,
|
|
required this.name,
|
|
required this.icon,
|
|
required this.type,
|
|
this.sortOrder,
|
|
});
|
|
|
|
factory Category.fromJson(Map<String, dynamic> json) => Category(
|
|
id: (json['id'] as num?)?.toInt() ?? 0,
|
|
name: json['name']?.toString() ?? '',
|
|
icon: json['icon']?.toString() ?? 'other',
|
|
type: (json['type'] as num?)?.toInt() ?? 1,
|
|
sortOrder: (json['sortOrder'] as num?)?.toInt(),
|
|
);
|
|
}
|