flutter_chat_list 0.0.1 flutter_chat_list: ^0.0.1 copied to clipboard
Provide enhanced list view include jump index, keep position etc.
Chat List #
Chat list library is based on flutter list view library to implement full chat list functionality.
Features #
- Support loading more and loading previous messages.
- Support keeping scroll position when user scroll to other position to read messages.
- Support scrolling to unread message.
- Support detecting receive message and tip new received messages
- Support timetag in messages
- Support load fragment messages and infine load prev messages
Screen #
Example #
Widget _renderList() {
return ChatList(
messageCount: messages?.length ?? 0,
itemBuilder: (BuildContext context, int index) => _renderItem(index),
onMessageKey: (int index) => messages![index].id,
controller: chatListController,
// New message tip
showNewMessageComingButton: true,
onIsReceiveMessage: (int i) => messages![i].type == MsgType.receive,
// Scroll to top
showScrollToTop: true,
);
}
More complex example
Widget _renderList() {
return ChatList(
messageCount: messages?.length ?? 0,
itemBuilder: (BuildContext context, int index) => _renderItem(index),
onMessageKey: (int index) => messages![index].id,
controller: chatListController,
// New message tip
showNewMessageComingButton: true,
newMessageComingButtonPosition: const Position(right: 0, bottom: 20),
// newMessageComingButtonBuilder: defaultNewMessageComingButtonBuilder,
onIsReceiveMessage: (int i) => messages![i].type == MsgType.receive,
// Scroll to top
showScrollToTop: true,
offsetToShowScrollToTop: 400.0,
// scrollToTopBuilder: defaultScrollToTopBuilder,
loadTopMessagesWhenJumpToTop: _loadTopMessagesWhenJumpToTop,
// Last read message
showLastReadMessageButton: true,
latestReadMessageKey: latestMessageKey,
latestUnreadMsgCount: unreadMsgCount,
lastReadMessageButtonPosition: const Position(right: 0, top: 20),
loadMoreMessagesWhileMissLatestMsg: _loadMoreMessagesWhileMissLatestMsg,
lastUnreadMsgOffsetFromTop: 50,
// lastReadMessageButtonBuilder: defaultLastReadMessageButtonBuilder,
// Refresh
hasMorePrevMessages: hasPrevMessages,
loadPrevMessageOffset: 100,
loadPrevWidgetBuilder: defaultLoadPrevWidgetBuilder,
loadPrevMessages: _loadPrevMessages,
// Load more
hasMoreNextMessages: hasMoreMessages,
loadNextMessageOffset: 10,
loadNextWidgetBuilder: defaultLoadNextWidgetBuilder,
loadNextMessages: _loadMoreMessages,
);
}