creek
The AI Image Editor of 2030git clone https://github.com/maydayv7/creek
lib/data/models/note_model.dart (1592B)
1class NoteModel {
2 final int? id;
3 final String imageId;
4 final String content;
5 final String category;
6 final DateTime createdAt;
7 final double normX;
8 final double normY;
9 final double normWidth;
10 final double normHeight;
11 final String? analysisData;
12 final String? cropFilePath;
13 final String status;
14
15 NoteModel({
16 this.id,
17 required this.imageId,
18 required this.content,
19 required this.category,
20 required this.createdAt,
21 this.normX = 0.5,
22 this.normY = 0.5,
23 this.normWidth = 0.0,
24 this.normHeight = 0.0,
25 this.analysisData,
26 this.cropFilePath,
27 this.status = 'pending',
28 });
29
30 Map<String, dynamic> toMap() {
31 return {
32 'id': id,
33 'image_id': imageId,
34 'content': content,
35 'category': category,
36 'created_at': createdAt.toIso8601String(),
37 'norm_x': normX,
38 'norm_y': normY,
39 'norm_width': normWidth,
40 'norm_height': normHeight,
41 'analysis_data': analysisData,
42 'crop_file_path': cropFilePath,
43 'status': status,
44 };
45 }
46
47 factory NoteModel.fromMap(Map<String, dynamic> map) {
48 return NoteModel(
49 id: map['id'],
50 imageId: map['image_id'],
51 content: map['content'],
52 category: map['category'],
53 createdAt: DateTime.parse(map['created_at']),
54 normX: map['norm_x'] ?? 0.5,
55 normY: map['norm_y'] ?? 0.5,
56 normWidth: map['norm_width'] ?? 0.0,
57 normHeight: map['norm_height'] ?? 0.0,
58 analysisData: map['analysis_data'],
59 cropFilePath: map['crop_file_path'],
60 status: map['status'] ?? 'pending',
61 );
62 }
63}