-2

I am using Stream chat API for the chat application. And while sending message I want to use the newline character in the textinput but I tried, the following code. It isn't working. And I am not finding any fixes, on the internet. Any help would be grateful appreciated.

                     child: TextField(
                          textInputAction: TextInputAction.newline,
                          keyboardType: TextInputType.multiline,
                          controller: controller,
                          onChanged: (val) {
                            StreamChannel.of(context).channel.keyStroke();
                          },
                          style: const TextStyle(fontSize: 14),
                          decoration: const InputDecoration(
                            hintText: 'Type something...',
                            border: InputBorder.none,
                          ),
                          onSubmitted: (_) => _sendMessage(),
                        ),
krishnaacharyaa
  • 14,953
  • 4
  • 49
  • 88

2 Answers2

1

When you hit the return or enter key the on submit _sendMessage() is called. Please try removing on submit and new line should work also make sure that the maxline is set to null so its not restricted to add any number of lines

Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30
1

In your TextField, add

   maxLines: null,

Or

   maxLines: 5,

whatever you want.

Wai Han Ko
  • 760
  • 5
  • 16