diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index fb8d18a49..f72f1e07d 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -9,6 +9,7 @@ - Added `StreamMediaAttachmentBuilder` widget to show media attachments in a message. - Added export for `message_widget_content_components.dart` to allow for easier customization of message content components. - Fixed error when channel image is not set. +- Extends predicates for sending and clearing messages to mobile. ## 7.2.1 diff --git a/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart b/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart index f0625974a..31fb8771d 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart @@ -377,16 +377,32 @@ class StreamMessageInput extends StatefulWidget { FocusNode node, KeyEvent event, ) { - // On desktop/web, send the message when the user presses the enter key. - return event is KeyUpEvent && event.logicalKey == LogicalKeyboardKey.enter; + if (CurrentPlatform.isWeb || + CurrentPlatform.isMacOS || + CurrentPlatform.isWindows || + CurrentPlatform.isLinux) { + // On desktop/web, send the message when the user presses the enter key. + return event is KeyUpEvent && + event.logicalKey == LogicalKeyboardKey.enter; + } + + return false; } static bool _defaultClearQuotedMessageKeyPredicate( FocusNode node, KeyEvent event, ) { - // On desktop/web, clear the quoted message when the user presses the escape key. - return event is KeyUpEvent && event.logicalKey == LogicalKeyboardKey.escape; + if (CurrentPlatform.isWeb || + CurrentPlatform.isMacOS || + CurrentPlatform.isWindows || + CurrentPlatform.isLinux) { + // On desktop/web, clear the quoted message when the user presses the escape key. + return event is KeyUpEvent && + event.logicalKey == LogicalKeyboardKey.escape; + } + + return false; } @override @@ -908,7 +924,11 @@ class StreamMessageInputState extends State onKeyEvent: _handleKeyPressed, child: child!, ), - mobile: (context, child) => child, + mobile: (context, child) => Focus( + skipTraversal: true, + onKeyEvent: _handleKeyPressed, + child: child!, + ), child: StreamMessageTextField( key: const Key('messageInputText'), maxLines: widget.maxLines,