@@ -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,16 @@ 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: DateTime .tryParse (json[_updatedAt]? .toString () ?? '' ) ??
81+ DateTime .tryParse (json[_updateAt].toString ()),
7682 );
7783 }
7884
7985 static const String _replyMessage = 'reply_message' ;
8086 static const String _reaction = 'reaction' ;
8187 static const String _voiceMessageDuration = 'voice_message_duration' ;
8288 static const String _updateAt = 'update_at' ;
89+ static const String _updatedAt = 'updated_at' ;
8390 static const String _update = 'update' ;
8491
8592 /// Unique identifier for the message.
@@ -106,7 +113,17 @@ class Message {
106113 /// {@macro chatview_utils.enumeration.MessageType}
107114 final MessageType messageType;
108115
109- final DateTime ? updateAt;
116+ /// The date and time when the message was last updated.
117+ final DateTime ? updatedAt;
118+
119+ /// Deprecated. Use [updatedAt] instead.
120+ ///
121+ /// This getter is kept for backward compatibility and will be removed
122+ /// in a future version.
123+ @Deprecated (
124+ 'Use updatedAt instead.' ,
125+ )
126+ DateTime ? get updateAt => updatedAt;
110127
111128 final Map <String , dynamic >? update;
112129
@@ -146,16 +163,16 @@ class Message {
146163 data[_replyMessage] = replyMessage.toJson ();
147164 data[_reaction] = reaction.toJson ();
148165 data[_voiceMessageDuration] = voiceMessageDuration? .inMicroseconds;
149- data[_updateAt ] = updateAt ? .toIso8601String ();
166+ data[_updatedAt ] = updatedAt ? .toIso8601String ();
150167 data[_update] = update;
151168 } else {
152169 if (! replyMessage.isEmpty) data[_replyMessage] = replyMessage.toJson ();
153170 if (! reaction.isEmpty) data[_reaction] = reaction.toJson ();
154171 if (voiceMessageDuration case final duration? ) {
155172 data[_voiceMessageDuration] = duration.inMicroseconds;
156173 }
157- if (updateAt case final updateAt ? ) {
158- data[_updateAt ] = updateAt .toIso8601String ();
174+ if (updatedAt case final updatedAt ? ) {
175+ data[_updatedAt ] = updatedAt .toIso8601String ();
159176 }
160177 if (update? .isNotEmpty ?? false ) data[_update] = update;
161178 }
@@ -173,10 +190,15 @@ class Message {
173190 MessageType ? messageType,
174191 Duration ? voiceMessageDuration,
175192 MessageStatus ? status,
193+ DateTime ? updatedAt,
194+ @Deprecated (
195+ 'Use updatedAt instead.' ,
196+ )
176197 DateTime ? updateAt,
177198 Map <String , String >? update,
178199 bool forceNullValue = false ,
179200 }) {
201+ final resolvedUpdatedAt = updatedAt ?? updateAt;
180202 return Message (
181203 id: id ?? this .id,
182204 message: message ?? this .message,
@@ -188,7 +210,9 @@ class Message {
188210 : voiceMessageDuration ?? this .voiceMessageDuration,
189211 reaction: reaction ?? this .reaction,
190212 replyMessage: replyMessage ?? this .replyMessage,
191- updateAt: forceNullValue ? updateAt : updateAt ?? this .updateAt,
213+ updatedAt: forceNullValue
214+ ? resolvedUpdatedAt
215+ : resolvedUpdatedAt ?? this .updatedAt,
192216 update: forceNullValue ? update : update ?? this .update,
193217 status: status ?? this .status,
194218 );
@@ -212,7 +236,7 @@ class Message {
212236 other.voiceMessageDuration == voiceMessageDuration &&
213237 other.status == status &&
214238 mapEquals (other.update, update) &&
215- other.updateAt == updateAt ;
239+ other.updatedAt == updatedAt ;
216240 }
217241
218242 @override
@@ -227,6 +251,6 @@ class Message {
227251 voiceMessageDuration,
228252 status,
229253 update,
230- updateAt ,
254+ updatedAt ,
231255 ]);
232256}
0 commit comments