flutter_chat_ui icon indicating copy to clipboard operation
flutter_chat_ui copied to clipboard

Ability to disable auto scroll

Open JHubi1 opened this issue 1 year ago • 5 comments

Is your feature request related to a problem?

At the moment, the chat view always scrolls to the bottom of the latest message if one is updated. In general, that is great, but there might be a situation in which a different behavior is needed.

What solution would you suggest?

I'd like to see a property value like autoscroll which is set to true by default and that toggles the scrolling to the bottom.

Code snippets 📝

Chat(
  messages: messages,
  key: chatKey,
  autoscroll: false
)

Is there any additional solution to that?

The function that scrolls to the bottom is made to an argument, so it can be overwritten with an empty function and the scroll would be disabled as well.

Code snippets 📝

Chat(
  messages: messages,
  key: chatKey,
  onNewMessage: (id) {}
)

Related issues/PRs

Issue #354 mentions the issue, but doesn't go into detail.

JHubi1 avatar Aug 22 '24 20:08 JHubi1

everything is going to v2 now, lately I have been working 2-3 hours a day for the past 2 weeks or so, with ai agent example as well, so it will be miles better for ai

demchenkoalex avatar Sep 02 '24 05:09 demchenkoalex

Hello, can you give us basic idea on how you gonna do it in v2? We are using v1.6 and we need to emulate ChatGPT and OpenAI bot SSE responses. I am not sure it possible to do it, without forking your package since the issue is not with scrolling, but rather with CustomScrollView. Maybe you can give us an idea. Thanks!

chechoora avatar Sep 18 '24 05:09 chechoora

Hey, there is no simple answer, I removed all code and started from scratch :) I already have working SSE responses on v2 branch. What is left for me is to add some basic customisation for text messages and I will release an alpha version. I hope to do finish it next week. If you can't wait you can try to grab v2 branch as an example, it will be miles better than what you see on main

demchenkoalex avatar Sep 20 '24 19:09 demchenkoalex

Hey @demchenkoalex , thanks for all your work you do on this package, we rely on it heavily. Looking forward to v2, is there any estimate for when you think a PR will be ready?

andrew-mezzi avatar Oct 23 '24 16:10 andrew-mezzi

hey @andrew-mezzi it's live already:) just need to sort out docs/github

demchenkoalex avatar Oct 23 '24 18:10 demchenkoalex

example of this is live in v2 https://github.com/flyerhq/flutter_chat_ui/issues/646

demchenkoalex avatar Oct 26 '24 22:10 demchenkoalex

@demchenkoalex Is this feature available in V2? If yes, could you share a code snippet? Thanks a lot for this great package btw. Now implementing chat is way easier than ever.

qasim90 avatar Apr 05 '25 12:04 qasim90

hey @qasim90 thanks! yes, it is available - check release notes for this release: v2.0.0-dev.4 - you are interested in List Behavior Controls section.

Chat(
  builders: Builders(
    chatAnimatedListBuilder: (context, itemBuilder) {
      return ChatAnimatedList( // or ChatAnimatedListReversed
        itemBuilder: itemBuilder,
        shouldScrollToEndWhenAtBottom: false,
        shouldScrollToEndWhenSendingMessage: false,
      );
    },
  ),
);

demchenkoalex avatar Apr 06 '25 10:04 demchenkoalex