student-legacy/refilc/lib/models/self_note.dart
2024-05-04 23:31:15 +02:00

36 lines
679 B
Dart

enum NoteType { text, image }
class SelfNote {
String id;
String? title;
String content;
NoteType noteType;
Map? json;
SelfNote({
required this.id,
this.title,
required this.content,
required this.noteType,
this.json,
});
factory SelfNote.fromJson(Map json) {
return SelfNote(
id: json['id'],
title: json['title'],
content: json['content'],
noteType: json['note_type'] == 'image' ? NoteType.image : NoteType.text,
json: json,
);
}
get toJson => {
'id': id,
'title': title,
'content': content,
'note_type': noteType == NoteType.image ? 'image' : 'text',
};
}