diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 7b59e694..6f86d9de 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -62,6 +62,7 @@ class MessageInput extends StatefulWidget { this.parentMessage, this.editMessage, this.maxHeight = 150, + this.keyboardType = TextInputType.multiline, }) : super(key: key); /// Message to edit @@ -76,6 +77,9 @@ class MessageInput extends StatefulWidget { /// Maximum Height for the TextField to grow before it starts scrolling final double maxHeight; + /// The keyboard type assigned to the TextField + final TextInputType keyboardType; + @override _MessageInputState createState() => _MessageInputState(); } @@ -93,20 +97,27 @@ class _MessageInputState extends State { @override Widget build(BuildContext context) { return SafeArea( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Stack( - overflow: Overflow.visible, - children: [ - _buildBorder(context), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _buildAttachments(), - _buildTextField(context), - ], - ), - ], + child: GestureDetector( + onPanUpdate: (details) { + if (details.delta.dy > 0) { + _focusNode.unfocus(); + } + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Stack( + overflow: Overflow.visible, + children: [ + _buildBorder(context), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildAttachments(), + _buildTextField(context), + ], + ), + ], + ), ), ), ); @@ -147,7 +158,7 @@ class _MessageInputState extends State { onSubmitted: (_) { _sendMessage(context); }, - keyboardType: TextInputType.text, + keyboardType: widget.keyboardType, controller: _textController, focusNode: _focusNode, onChanged: (s) {