Dash-Chat-2
Dash-Chat-2 copied to clipboard
Can't scroll using arrow keys after we tap on dashchat
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,
),
)