creek
The AI Image Editor of 2030git clone https://github.com/maydayv7/creek
lib/data/models/image_model.dart (1269B)
1import 'dart:convert';
2
3class ImageModel {
4 final String id;
5 final int projectId;
6 final String filePath;
7 final String name;
8 final List<String> tags;
9 final String? analysisData;
10 final DateTime createdAt;
11 final String status; // 'pending', 'analyzing', 'completed', 'failed'
12
13 ImageModel({
14 required this.id,
15 required this.projectId,
16 required this.filePath,
17 required this.name,
18 this.tags = const [],
19 this.analysisData,
20 required this.createdAt,
21 this.status = 'pending',
22 });
23
24 Map<String, dynamic> toMap() {
25 return {
26 'id': id,
27 'project_id': projectId,
28 'file_path': filePath,
29 'name': name,
30 'tags': jsonEncode(tags),
31 'analysis_data': analysisData,
32 'created_at': createdAt.toIso8601String(),
33 'status': status,
34 };
35 }
36
37 factory ImageModel.fromMap(Map<String, dynamic> map) {
38 return ImageModel(
39 id: map['id'],
40 projectId: map['project_id'],
41 filePath: map['file_path'],
42 name: map['name'] ?? 'Untitled',
43 tags:
44 map['tags'] != null ? List<String>.from(jsonDecode(map['tags'])) : [],
45 analysisData: map['analysis_data'],
46 createdAt: DateTime.parse(map['created_at']),
47 status: map['status'] ?? 'pending',
48 );
49 }
50}