@@ -132,6 +132,13 @@ class Composer extends StatefulWidget {
132132 /// and hide the button. Defaults to `false` .
133133 final bool sendButtonHidden;
134134
135+ /// Whether to send messages on enter.
136+ ///
137+ /// If `true` , typing enter will send the message, and typing shift+enter
138+ /// will type enter. If `false` , typing shift+enter will send the message.
139+ /// Defaults to `false` .
140+ final bool sendOnEnter;
141+
135142 /// Controls the behavior of the text input field after a message is sent.
136143 /// Defaults to [InputClearMode.always] .
137144 final InputClearMode inputClearMode;
@@ -182,6 +189,7 @@ class Composer extends StatefulWidget {
182189 this .allowEmptyMessage = false ,
183190 this .sendButtonDisabled = false ,
184191 this .sendButtonHidden = false ,
192+ this .sendOnEnter = false ,
185193 this .inputClearMode = InputClearMode .always,
186194 this .contentInsertionConfiguration,
187195 });
@@ -211,7 +219,7 @@ class _ComposerState extends State<Composer> {
211219 // Check for Shift+Enter
212220 if (event is KeyDownEvent &&
213221 event.logicalKey == LogicalKeyboardKey .enter &&
214- HardwareKeyboard .instance.isShiftPressed) {
222+ widget.sendOnEnter ^ HardwareKeyboard .instance.isShiftPressed) {
215223 _handleSubmitted (_textController.text);
216224 return KeyEventResult .handled;
217225 }
0 commit comments