From 91b5d55a83d659fe07d0542a8093f8c247880a67 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 27 Apr 2019 10:13:29 +0200 Subject: [PATCH] Limit new messages length --- lib/ui/screens/conversation_screen.dart | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/ui/screens/conversation_screen.dart b/lib/ui/screens/conversation_screen.dart index a07afdd..2272039 100644 --- a/lib/ui/screens/conversation_screen.dart +++ b/lib/ui/screens/conversation_screen.dart @@ -244,14 +244,29 @@ class _ConversationScreenState extends State { // Message area new Flexible( child: new TextField( + maxLines: null, + maxLength: 200, + maxLengthEnforced: true, + + // Show max length only when there is some text already typed + buildCounter: ( + BuildContext context, { + @required int currentLength, + @required int maxLength, + @required bool isFocused, + }) => + currentLength > 0 + ? Text("$currentLength/$maxLength") + : Container(), enabled: !_isSendingMessage, controller: _textEditingController, onChanged: _updatedText, onSubmitted: _isMessageValid ? (s) => _submitTextMessage(context, s) : null, - decoration: - new InputDecoration.collapsed(hintText: tr("Send a message")), + decoration: new InputDecoration.collapsed( + hintText: tr("Send a message"), + ), ), ),