@@ -853,6 +853,107 @@ ChatView(
853853 lastSeenAgoBuilderVisibility: false,
854854 receiptsBuilderVisibility: false,
855855 enableTextSelection: true,
856+ enableEditMessage: true, // Enable the Edit Message feature (default: true)
857+ ),
858+ // ...
859+ )
860+ ```
861+
862+ ## Edit Message Feature
863+
864+ ChatView supports editing previously sent text messages, similar to WhatsApp and Telegram.
865+
866+ ### How It Works
867+
868+ 1 . Long-press a message bubble sent by the current user.
869+ 2 . Tap ** Edit** in the reply pop-up.
870+ 3 . The original text is pre-filled into the input field with an * Editing* indicator above it.
871+ 4 . Modify the text and press Send.
872+ 5 . Your ` onEditTap ` callback is called with the ** original ` Message ` ** and the ** new text** .
873+ 6 . Messages that have been edited display a subtle * Edited* label below the bubble.
874+
875+ ### Basic Integration
876+
877+ ``` dart
878+ ChatView(
879+ // ...
880+ onEditTap: (Message originalMessage, String newText) {
881+ // Update the message in your data source / backend.
882+ // Set `updateAt` on the message to trigger the "Edited" label in the UI.
883+ final updatedMessage = Message(
884+ id: originalMessage.id,
885+ message: newText,
886+ createdAt: originalMessage.createdAt,
887+ sentBy: originalMessage.sentBy,
888+ updateAt: DateTime.now(), // marks the message as edited
889+ replyMessage: originalMessage.replyMessage,
890+ messageType: originalMessage.messageType,
891+ );
892+
893+ chatController.updateMessage(updatedMessage); // depends on your controller API
894+ },
895+ replyPopupConfig: ReplyPopupConfiguration(
896+ // Optional: react to the edit tap in the popup before the editing UI opens.
897+ onEditTap: (message) => debugPrint('Editing: ${message.id}'),
898+ ),
899+ // ...
900+ )
901+ ```
902+
903+ ### Disabling the Feature
904+
905+ ``` dart
906+ ChatView(
907+ featureActiveConfig: const FeatureActiveConfig(
908+ enableEditMessage: false, // hides the Edit button entirely
909+ ),
910+ )
911+ ```
912+
913+ ### Localization
914+
915+ The edit-related strings can be customized via ` ChatViewLocale ` :
916+
917+ ``` dart
918+ PackageStrings.addLocaleObject(
919+ 'es',
920+ const ChatViewLocale(
921+ // ... all other required fields ...
922+ edit: 'Editar',
923+ edited: 'Editado',
924+ editing: 'Editando',
925+ ),
926+ );
927+ PackageStrings.setLocale('es');
928+ ```
929+
930+ ### Static Helper
931+
932+ Use ` ChatView.getEditingMessage(context) ` to read the message currently being edited
933+ from a widget that is a descendant of ` ChatView ` :
934+
935+ ``` dart
936+ final editingMsg = ChatView.getEditingMessage(context);
937+ if (editingMsg != null) {
938+ // User is in edit mode for editingMsg.
939+ }
940+ ```
941+
942+ ### Customizing the Edit Indicator Label
943+
944+ When a user enters edit mode, an indicator bar is displayed above the text field showing a label
945+ (default: locale-resolved ` "Editing" ` ). You can override this label via ` SendMessageConfiguration ` :
946+
947+ ``` dart
948+ ChatView(
949+ // ...
950+ sendMessageConfig: SendMessageConfiguration(
951+ /// The label shown in the editing indicator bar above the text field
952+ /// when the user is editing an existing message.
953+ ///
954+ /// If omitted, falls back to the locale-resolved value of
955+ /// `PackageStrings.currentLocale.editing` (e.g. `"Editing"`).
956+ editLabel: 'Editing message',
856957 ),
857958 // ...
858959)
0 commit comments