added persistence using shared preferences

This commit is contained in:
2025-09-19 20:43:38 +02:00
parent 12459bb4cb
commit d0feca1ba8
9 changed files with 301 additions and 15 deletions

View File

@@ -1,10 +1,18 @@
class Collection {
Collection({required this.name});
Collection({required this.name, int? createdAt})
: createdAt = createdAt ?? DateTime.now().millisecondsSinceEpoch;
factory Collection.fromJson(Map<String, dynamic> json) =>
Collection(name: json['name'] as String);
factory Collection.fromJson(Map<String, dynamic> json) => Collection(
name: json['name'] as String,
createdAt: json['createdAt'] as int,
);
String name;
int createdAt; // used as Id with millisecondsSinceEpoch
Map<String, dynamic> toJson() => {'name': name};
int get id => createdAt;
DateTime get createdDate => DateTime.fromMillisecondsSinceEpoch(createdAt);
Map<String, dynamic> toJson() => {'name': name, 'createdAt': createdAt};
}