@@ -36,11 +36,16 @@ class Message {
3636 this .replyMessage = const ReplyMessage (),
3737 this .messageType = MessageType .text,
3838 this .voiceMessageDuration,
39- this .updateAt,
39+ DateTime ? updatedAt,
40+ @Deprecated (
41+ 'Use updatedAt instead.' ,
42+ )
43+ DateTime ? updateAt,
4044 this .update,
4145 MessageStatus status = MessageStatus .pending,
4246 Reaction ? reaction,
43- }) : reaction = reaction ?? Reaction (reactions: [], reactedUserIds: []),
47+ }) : updatedAt = updatedAt ?? updateAt,
48+ reaction = reaction ?? Reaction (reactions: [], reactedUserIds: []),
4449 _status = ValueNotifier (status),
4550 assert (
4651 defaultTargetPlatform.isAudioWaveformsSupported ||
@@ -72,14 +77,24 @@ class Message {
7277 status: MessageStatus .tryParse (json['status' ]? .toString ()) ??
7378 MessageStatus .pending,
7479 update: updateData is Map <String , dynamic > ? updateData : null ,
75- updateAt: DateTime .tryParse (json[_updateAt].toString ()),
80+ updatedAt: () {
81+ final updatedAtStr = json[_updatedAt]? .toString ();
82+ final updateAtStr = json[_updateAt]? .toString ();
83+ return (updatedAtStr? .isNotEmpty ?? false
84+ ? DateTime .tryParse (updatedAtStr! )
85+ : null ) ??
86+ (updateAtStr? .isNotEmpty ?? false
87+ ? DateTime .tryParse (updateAtStr! )
88+ : null );
89+ }(),
7690 );
7791 }
7892
7993 static const String _replyMessage = 'reply_message' ;
8094 static const String _reaction = 'reaction' ;
8195 static const String _voiceMessageDuration = 'voice_message_duration' ;
8296 static const String _updateAt = 'update_at' ;
97+ static const String _updatedAt = 'updated_at' ;
8398 static const String _update = 'update' ;
8499
85100 /// Unique identifier for the message.
@@ -106,7 +121,17 @@ class Message {
106121 /// {@macro chatview_utils.enumeration.MessageType}
107122 final MessageType messageType;
108123
109- final DateTime ? updateAt;
124+ /// The date and time when the message was last updated.
125+ final DateTime ? updatedAt;
126+
127+ /// Deprecated. Use [updatedAt] instead.
128+ ///
129+ /// This getter is kept for backward compatibility and will be removed
130+ /// in a future version.
131+ @Deprecated (
132+ 'Use updatedAt instead.' ,
133+ )
134+ DateTime ? get updateAt => updatedAt;
110135
111136 final Map <String , dynamic >? update;
112137
@@ -146,16 +171,18 @@ class Message {
146171 data[_replyMessage] = replyMessage.toJson ();
147172 data[_reaction] = reaction.toJson ();
148173 data[_voiceMessageDuration] = voiceMessageDuration? .inMicroseconds;
149- data[_updateAt] = updateAt? .toIso8601String ();
174+ data[_updatedAt] = updatedAt? .toIso8601String ();
175+ data[_updateAt] = updatedAt? .toIso8601String ();
150176 data[_update] = update;
151177 } else {
152178 if (! replyMessage.isEmpty) data[_replyMessage] = replyMessage.toJson ();
153179 if (! reaction.isEmpty) data[_reaction] = reaction.toJson ();
154180 if (voiceMessageDuration case final duration? ) {
155181 data[_voiceMessageDuration] = duration.inMicroseconds;
156182 }
157- if (updateAt case final updateAt? ) {
158- data[_updateAt] = updateAt.toIso8601String ();
183+ if (updatedAt case final updatedAt? ) {
184+ data[_updatedAt] = updatedAt.toIso8601String ();
185+ data[_updateAt] = updatedAt.toIso8601String ();
159186 }
160187 if (update? .isNotEmpty ?? false ) data[_update] = update;
161188 }
@@ -173,10 +200,15 @@ class Message {
173200 MessageType ? messageType,
174201 Duration ? voiceMessageDuration,
175202 MessageStatus ? status,
203+ DateTime ? updatedAt,
204+ @Deprecated (
205+ 'Use updatedAt instead.' ,
206+ )
176207 DateTime ? updateAt,
177- Map <String , String >? update,
208+ Map <String , dynamic >? update,
178209 bool forceNullValue = false ,
179210 }) {
211+ final resolvedUpdatedAt = updatedAt ?? updateAt;
180212 return Message (
181213 id: id ?? this .id,
182214 message: message ?? this .message,
@@ -188,7 +220,9 @@ class Message {
188220 : voiceMessageDuration ?? this .voiceMessageDuration,
189221 reaction: reaction ?? this .reaction,
190222 replyMessage: replyMessage ?? this .replyMessage,
191- updateAt: forceNullValue ? updateAt : updateAt ?? this .updateAt,
223+ updatedAt: forceNullValue
224+ ? resolvedUpdatedAt
225+ : resolvedUpdatedAt ?? this .updatedAt,
192226 update: forceNullValue ? update : update ?? this .update,
193227 status: status ?? this .status,
194228 );
@@ -212,7 +246,7 @@ class Message {
212246 other.voiceMessageDuration == voiceMessageDuration &&
213247 other.status == status &&
214248 mapEquals (other.update, update) &&
215- other.updateAt == updateAt ;
249+ other.updatedAt == updatedAt ;
216250 }
217251
218252 @override
@@ -227,6 +261,6 @@ class Message {
227261 voiceMessageDuration,
228262 status,
229263 update,
230- updateAt ,
264+ updatedAt ,
231265 ]);
232266}
0 commit comments