diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 2105bc934..27a1a4806 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +🐞 Fixed + +- Fixed copy message function. + ## 7.2.2 ✅ Added diff --git a/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart index a8de9bb6b..30b75717a 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart @@ -816,12 +816,11 @@ class _StreamMessageWidgetState extends State title: Text(context.translations.copyMessageLabel), onClick: () { Navigator.of(context, rootNavigator: true).pop(); - final text = widget.message.text; - String? messageToCopy; + var messageToCopy = widget.message.text; for (final user in widget.message.mentionedUsers.toSet()) { final userId = user.id; final userName = user.name; - messageToCopy = text?.replaceAll( + messageToCopy = messageToCopy?.replaceAll( RegExp('@($userId|$userName)'), '@$userName', ) ?? @@ -1040,12 +1039,11 @@ class _StreamMessageWidgetState extends State : DisplayWidget.show, ), onCopyTap: (message) { - final text = message.text; - String? messageToCopy; + var messageToCopy = message.text; for (final user in widget.message.mentionedUsers.toSet()) { final userId = user.id; final userName = user.name; - messageToCopy = text?.replaceAll( + messageToCopy = messageToCopy?.replaceAll( RegExp('@($userId|$userName)'), '@$userName', ) ??