@@ -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,18 @@ 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 ();
167+ data[_updateAt] = updatedAt? .toIso8601String ();
150168 data[_update] = update;
151169 } else {
152170 if (! replyMessage.isEmpty) data[_replyMessage] = replyMessage.toJson ();
153171 if (! reaction.isEmpty) data[_reaction] = reaction.toJson ();
154172 if (voiceMessageDuration case final duration? ) {
155173 data[_voiceMessageDuration] = duration.inMicroseconds;
156174 }
157- if (updateAt case final updateAt? ) {
158- data[_updateAt] = updateAt.toIso8601String ();
175+ if (updatedAt case final updatedAt? ) {
176+ data[_updatedAt] = updatedAt.toIso8601String ();
177+ data[_updateAt] = updatedAt.toIso8601String ();
159178 }
160179 if (update? .isNotEmpty ?? false ) data[_update] = update;
161180 }
@@ -173,10 +192,15 @@ class Message {
173192 MessageType ? messageType,
174193 Duration ? voiceMessageDuration,
175194 MessageStatus ? status,
195+ DateTime ? updatedAt,
196+ @Deprecated (
197+ 'Use updatedAt instead.' ,
198+ )
176199 DateTime ? updateAt,
177- Map <String , String >? update,
200+ Map <String , dynamic >? update,
178201 bool forceNullValue = false ,
179202 }) {
203+ final resolvedUpdatedAt = updatedAt ?? updateAt;
180204 return Message (
181205 id: id ?? this .id,
182206 message: message ?? this .message,
@@ -188,7 +212,11 @@ class Message {
188212 : voiceMessageDuration ?? this .voiceMessageDuration,
189213 reaction: reaction ?? this .reaction,
190214 replyMessage: replyMessage ?? this .replyMessage,
191- updateAt: forceNullValue ? updateAt : updateAt ?? this .updateAt,
215+ updatedAt: forceNullValue
216+ ? resolvedUpdatedAt
217+ : resolvedUpdatedAt ?? this .updatedAt,
218+ // this.updateAt is stored in the local updatedAt variable
219+ // so no need to pass this.updateAt
192220 update: forceNullValue ? update : update ?? this .update,
193221 status: status ?? this .status,
194222 );
@@ -212,7 +240,7 @@ class Message {
212240 other.voiceMessageDuration == voiceMessageDuration &&
213241 other.status == status &&
214242 mapEquals (other.update, update) &&
215- other.updateAt == updateAt ;
243+ other.updatedAt == updatedAt ;
216244 }
217245
218246 @override
@@ -227,6 +255,6 @@ class Message {
227255 voiceMessageDuration,
228256 status,
229257 update,
230- updateAt ,
258+ updatedAt ,
231259 ]);
232260}
0 commit comments