Refactored json storage
This commit is contained in:
31
lib/repositories/metadata/models/account.dart
Normal file
31
lib/repositories/metadata/models/account.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'dart:ui';
|
||||
|
||||
class Account {
|
||||
String label;
|
||||
String color;
|
||||
bool saving;
|
||||
|
||||
Account({
|
||||
this.label = '',
|
||||
this.color = '',
|
||||
this.saving = false,
|
||||
});
|
||||
|
||||
factory Account.fromJson(Map<String, dynamic> json) {
|
||||
return Account(
|
||||
label: json['label'],
|
||||
color: json['color'],
|
||||
saving: bool.parse(json['saving']),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, String> toJson() => {
|
||||
'label': label,
|
||||
'color': color,
|
||||
'saving': saving.toString(),
|
||||
};
|
||||
|
||||
Color rgbToColor() {
|
||||
return Color(int.parse(color.toUpperCase().replaceAll("#", ""), radix: 16));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user