Dash-Chat-2 icon indicating copy to clipboard operation
Dash-Chat-2 copied to clipboard

Can't scroll using arrow keys after we tap on dashchat

Open KiraKami-dev opened this issue 8 months ago • 0 comments

When scrolling in the messages list i am facing an issue where when i tap on the dashChat widget the focus goes away meaning i can't scroll anymore. I tried passing around the _focusNode.requestFocus() but it didn't seem to work as well. It would be great if you could help me with this.

Below is an small code snippet :

Variable :

final ScrollController _scrollController = ScrollController();
  final FocusNode _focusNode = FocusNode();
Keyboard listener for arrow keys :

KeyboardListener(
          focusNode: _focusNode,
          autofocus: true,
          onKeyEvent: (event) {
            if (event is KeyDownEvent &&
                event.logicalKey == LogicalKeyboardKey.arrowUp) {
              print("Arrow up pressed");
              _scrollController.animateTo(_scrollController.offset + 100,
                  duration: Duration(milliseconds: 200),
                  curve: Curves.fastEaseInToSlowEaseOut);
            } else if (event is KeyDownEvent &&
                event.logicalKey == LogicalKeyboardKey.arrowDown) {
              print("Arrow down pressed");
              _scrollController.animateTo(_scrollController.offset - 100,
                  duration: Duration(milliseconds: 200),
                  curve: Curves.fastEaseInToSlowEaseOut);
            }
          },

Passing scroll to dashChat :

DashChat(
  typingUsers: botTyping,
  currentUser: myself,
  messages: allMessage,
  messageListOptions: MessageListOptions(
    scrollController: _scrollController,
    ),
    )

KiraKami-dev avatar Jun 15 '24 05:06 KiraKami-dev