dash_chat icon indicating copy to clipboard operation
dash_chat copied to clipboard

new message chat content not scroll to latest

Open athlona64 opened this issue 4 years ago • 15 comments

Describe the bug when have new message chatbox content not scroll to latest is freezing

athlona64 avatar Apr 08 '20 09:04 athlona64

This happen when the list view content's height exceed visible rect.

nguyenvanzk avatar Apr 14 '20 01:04 nguyenvanzk

how to solve

athlona64 avatar Apr 17 '20 03:04 athlona64

You can use the method animateTo from scrollController, here is the example

final scrollController = _chatViewKey.currentState.scrollController;

scrollController.animateTo(
  scrollController.position.maxScrollExtent,
  curve: Curves.easeOut,
  duration: Duration(milliseconds: 300),
);

Don't forget to define the GlobalKey (_chatViewKey)

final _chatViewKey = GlobalKey<DashChatState>();

// ... and on build method
return DashChat(
  key: _chatViewKey,
);

hjJunior avatar Apr 27 '20 13:04 hjJunior

This doesn't actually solve the problem as well too. Not sure what's going on. It seems that with the visibility of the virtual keyboard, the new message is not going to it by default. One thing I tried was to increase my delay time before triggering the scrolling duration. That seems to be helpful in a lot more cases, but that didn't exactly fix it either.

ngoctranfire avatar May 13 '20 04:05 ngoctranfire

Also, if there are lots of images, which will render lazily, the messageListView will not scroll to latest message.

sijangurung avatar Jun 05 '20 19:06 sijangurung

same issue on 1.1.5

albrownwood avatar Jun 08 '20 02:06 albrownwood

one solution to this is to set inverse: true. But then you have to get the messages in ascending order and do some custom logic.

sijangurung avatar Jun 08 '20 08:06 sijangurung

Any news?

0xmikko avatar Jul 14 '20 20:07 0xmikko

I think it makes sense to add a parameter to the DashChat constuctor enabling that behavior, it looks like a very common use case.

vzctl avatar Jul 24 '20 19:07 vzctl

Hi all, I stored messages and when I reopen chat window, it is stay on the top so I used scroll control. Even though, it is not working properly. I mean last message behind on input bar. Is there any solutions for this? Thanks

fluttercid avatar Aug 05 '20 13:08 fluttercid

Hi @fluttercid, in that case you maybe have a margin issue, you can use inputToolbarMargin for that

SebastienBtr avatar Aug 18 '20 09:08 SebastienBtr

Thank you for your answer @SebastienBtr I tried your suggestion; however, it is not working. I think messageviewlist height is include input box. I made a document for it. explain about situation.docx

fluttercid avatar Aug 28 '20 12:08 fluttercid

Scroll Issue

i'm facing the same scroll issue in different scenario, whenever i try to open the dashchat or send a new message it stops before 1 or 2 recent messages, it's not fully scroll to bottom. This issue is happening for the scroll to bottom default button too. i'm using below line of codes to scroll.

_chatViewKey.currentState.scrollController.animateTo( _chatViewKey.currentState.scrollController.position.maxScrollExtent, curve: Curves.easeOut, duration: const Duration(milliseconds: 100), );

Thanks in advance

SubashManian avatar Sep 30 '20 15:09 SubashManian

I am also facing @SubashManian 's issue. Is there any hacky way to fix it?? And is there any documentation for how internals of this package works. I could help out maybe.

mustafapc19 avatar Dec 09 '20 14:12 mustafapc19

One workaround is to use a small delay after sending message and then scroll

     await  Future.delayed(Duration(milliseconds: 500));
    _chatViewKey.currentState.scrollController.animateTo(
      _chatViewKey.currentState.scrollController.position.maxScrollExtent,
      curve: Curves.easeOut,
      duration: const Duration(milliseconds: 100),
    );

ritheshSalyan avatar Feb 04 '21 16:02 ritheshSalyan