Files
Krezus/lib/repositories/account/models/category.dart
2024-02-14 23:41:50 +01:00

36 lines
717 B
Dart

import 'dart:ui';
class Category {
String label;
String color;
bool essential;
bool saving;
Category({
this.label = '',
this.color = '',
this.essential = false,
this.saving = false,
});
factory Category.fromJson(Map<String, dynamic> json) {
return Category(
label: json['label'],
color: json['color'],
essential: bool.parse(json['essential']),
saving: bool.parse(json['saving']),
);
}
Map<String, String> toJson() => {
'label': label,
'color': color,
'essential': essential.toString(),
'saving': saving.toString(),
};
Color rgbToColor() {
return Color(int.parse(color.toUpperCase().replaceAll("#", ""), radix: 16));
}
}