added persistence using shared preferences
This commit is contained in:
@@ -1,11 +1,35 @@
|
||||
class Bookmark {
|
||||
Bookmark({required this.name, required this.link});
|
||||
Bookmark({
|
||||
required this.collectionId,
|
||||
required this.name,
|
||||
required this.link,
|
||||
required this.description,
|
||||
int? createdAt,
|
||||
}) : createdAt = createdAt ?? DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
factory Bookmark.fromJson(Map<String, dynamic> json) =>
|
||||
Bookmark(name: json['name'] as String, link: json['link'] as String);
|
||||
factory Bookmark.fromJson(Map<String, dynamic> json) => Bookmark(
|
||||
collectionId: json['collectionId'] as int,
|
||||
name: json['name'] as String,
|
||||
link: json['link'] as String,
|
||||
description: json['description'] as String,
|
||||
createdAt: json['createdAt'] as int,
|
||||
);
|
||||
|
||||
int collectionId;
|
||||
String link;
|
||||
String name;
|
||||
String description;
|
||||
int createdAt;
|
||||
|
||||
Map<String, dynamic> toJson() => {'name': name, 'link': link};
|
||||
int get id => createdAt;
|
||||
|
||||
DateTime get createdDate => DateTime.fromMillisecondsSinceEpoch(createdAt);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'collectionId': collectionId,
|
||||
'name': name,
|
||||
'link': link,
|
||||
'description': description,
|
||||
'createdAt': createdAt,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user