Fix Hive Timestamp serialization
This commit is contained in:
@@ -21,7 +21,9 @@ class AlarmData {
|
|||||||
factory AlarmData.fromMap(Map<String, dynamic> map) {
|
factory AlarmData.fromMap(Map<String, dynamic> map) {
|
||||||
return AlarmData(
|
return AlarmData(
|
||||||
id: map['id'] ?? '',
|
id: map['id'] ?? '',
|
||||||
dateTime: (map['dateTime'] as Timestamp).toDate(),
|
dateTime: map['dateTime'] is Timestamp
|
||||||
|
? (map['dateTime'] as Timestamp).toDate()
|
||||||
|
: DateTime.parse(map['dateTime'] as String),
|
||||||
isRepeating: map['isRepeating'] ?? false,
|
isRepeating: map['isRepeating'] ?? false,
|
||||||
repeatPattern: map['repeatPattern'] ?? 'daily',
|
repeatPattern: map['repeatPattern'] ?? 'daily',
|
||||||
repeatDays: List<int>.from(map['repeatDays'] ?? []),
|
repeatDays: List<int>.from(map['repeatDays'] ?? []),
|
||||||
@@ -32,7 +34,7 @@ class AlarmData {
|
|||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
'id': id,
|
'id': id,
|
||||||
'dateTime': Timestamp.fromDate(dateTime),
|
'dateTime': dateTime.toIso8601String(), // Сохраняем как строку для Hive
|
||||||
'isRepeating': isRepeating,
|
'isRepeating': isRepeating,
|
||||||
'repeatPattern': repeatPattern,
|
'repeatPattern': repeatPattern,
|
||||||
'repeatDays': repeatDays,
|
'repeatDays': repeatDays,
|
||||||
|
|||||||
Reference in New Issue
Block a user