release: seal Focus Seed 1.0.0
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
class Habit {
|
||||
const Habit({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.createdAt,
|
||||
required this.completedDates,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String title;
|
||||
final DateTime createdAt;
|
||||
final Set<String> completedDates;
|
||||
|
||||
Habit copyWith({String? title, Set<String>? completedDates}) {
|
||||
return Habit(
|
||||
id: id,
|
||||
title: title ?? this.title,
|
||||
createdAt: createdAt,
|
||||
completedDates: completedDates ?? this.completedDates,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'completedDates': completedDates.toList()..sort(),
|
||||
};
|
||||
}
|
||||
|
||||
static Habit fromJson(Map<String, dynamic> json) {
|
||||
return Habit(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
createdAt: DateTime.parse(json['createdAt'] as String),
|
||||
completedDates:
|
||||
((json['completedDates'] as List?) ?? const [])
|
||||
.map((value) => value.toString())
|
||||
.toSet(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user