flutter_chat_list 1.0.5 copy "flutter_chat_list: ^1.0.5" to clipboard
flutter_chat_list: ^1.0.5 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 #

  1. Support loading more and loading previous messages.
  2. Support keeping scroll position when user scroll to other position to read messages.
  3. Support scrolling to unread message.
  4. Support detecting receive message and tip new received messages
  5. Support timetag in messages
  6. Support load fragment messages and infine load prev messages

Screen #

Example #

Widget _renderList() {
  return ChatList(
    msgCount: messages?.length ?? 0,
    itemBuilder: (BuildContext context, int index) => _renderItem(index),
    onMsgKey: (int index) => messages![index].id,
    controller: chatListController,
    // New message tip
    showReceivedMsgButton: true,
    onIsReceiveMessage: (int i) => messages![i].type == MsgType.receive,

    // Scroll to top
    showScrollToTopButton: true,
  );
}

More complex example

Widget _renderList() {
  return ChatList(
    msgCount: messages?.length ?? 0,
    itemBuilder: (BuildContext context, int index) => _renderItem(index),
    onMsgKey: (int index) => messages![index].id,
    controller: chatListController,
    // New message tip
    showReceivedMsgButton: true,
    receivedMsgButtonPosition: const Position(right: 0, bottom: 20),
    // newMessageComingButtonBuilder: defaultNewMessageComingButtonBuilder,
    onIsReceiveMessage: (int i) => messages![i].type == MsgType.receive,

    // Scroll to top
    showScrollToTopButton: true,
    offsetToShowScrollToTop: 400.0,
    // scrollToTopBuilder: defaultScrollToTopBuilder,
    onLoadTopMsgs: _loadTopMessagesWhenJumpToTop,

    // Last read message
    showUnreadMsgButton: true,
    latestReadMsgKey: latestMessageKey,
    unreadMsgCount: unreadMsgCount,
    unreadMsgButtonPosition: const Position(right: 0, top: 20),
    onLoadMsgsByLatestReadMsgKey: _loadMoreMessagesWhileMissLatestMsg,
    offsetFromUnreadTipToTop: 50,
    // lastReadMessageButtonBuilder: defaultLastReadMessageButtonBuilder,

    // Refresh
    hasPrevMsgs: hasPrevMessages,
    offsetToTriggerLoadPrev: 100,
    loadPrevProgressBuilder: defaultLoadPrevProgressBuilder,
    onLoadPrevMsgs: _loadPrevMessages,

    // Load more
    hasMoreMsgs: hasMoreMessages,
    offsetToTriggerLoadMore: 10,
    loadMoreProgressBuilder: defaultLoadMoreProgressBuilder,
    onLoadMoreMsgs: _loadMoreMessages,
  );
}
8
likes
140
pub points
80%
popularity

Publisher

unverified uploader

Provide enhanced list view include jump index, keep position etc.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_list_view, pull_to_refresh

More

Packages that depend on flutter_chat_list