Files
maps_bookmarks/lib/model/collection.dart

19 lines
553 B
Dart

class Collection {
Collection({required this.name, int? createdAt})
: createdAt = createdAt ?? DateTime.now().millisecondsSinceEpoch;
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
int get id => createdAt;
DateTime get createdDate => DateTime.fromMillisecondsSinceEpoch(createdAt);
Map<String, dynamic> toJson() => {'name': name, 'createdAt': createdAt};
}