MessageListView class

screenshot screenshot

It shows the list of messages of the current channel.

class ChannelPage extends StatelessWidget {
  const ChannelPage({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: ChannelHeader(),
      body: Column(
        children: <Widget>[
          Expanded(
            child: MessageListView(
              threadBuilder: (_, parentMessage) {
                return ThreadPage(
                  parent: parentMessage,
                );
              },
            ),
          ),
          MessageInput(),
        ],
      ),
    );
  }
}

Make sure to have a StreamChannel ancestor in order to provide the information about the channels. The widget uses a ListView.custom to render the list of channels.

The widget components render the ui based on the first ancestor of type StreamChatTheme. Modify it to change the widget appearance.

Inheritance

Constructors

MessageListView({Key key, bool showScrollToBottom, MessageBuilder messageBuilder, ParentMessageBuilder parentMessageBuilder, Message parentMessage, ThreadBuilder threadBuilder, ThreadTapCallback onThreadTap, ReplyTapCallback onReplyTap, Widget dateDividerBuilder(DateTime), ScrollPhysics scrollPhysics, int initialScrollIndex, double initialAlignment, ItemScrollController scrollController, ItemPositionsListener itemPositionListener, OnMessageSwiped onMessageSwiped, bool highlightInitialMessage, Color messageHighlightColor, ShowMessageCallback onShowMessage, bool showConnectionStateTile, WidgetBuilder loadingBuilder, WidgetBuilder emptyBuilder, SystemMessageBuilder systemMessageBuilder, Widget messageListBuilder(BuildContext, List<Message>), ErrorBuilder errorWidgetBuilder, bool messageFilter(Message), Map<String, AttachmentBuilder> customAttachmentBuilders, OnMessageTap onMessageTap, OnMessageTap onSystemMessageTap, void onAttachmentTap(Message message, Attachment attachment), void textBuilder(BuildContext context, Message message)})
Instantiate a new MessageListView

Properties

customAttachmentBuilders Map<String, AttachmentBuilder>
Attachment builders for the default message widget Please change this in the MessageWidget if you are using a custom implementation
final
dateDividerBuilder Widget Function(DateTime)
Builder used to render date dividers
final
emptyBuilder WidgetBuilder
Function used to build an empty widget
final
errorWidgetBuilder ErrorBuilder
Callback triggered when an error occurs while performing the given request. This parameter can be used to display an error message to users in the event of a connection failure.
final
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
highlightInitialMessage bool
If true the list will highlight the initialMessage if there is any. [...]
final
initialAlignment double
Determines where the leading edge of the item at initialScrollIndex should be placed.
final
initialScrollIndex int
Index of an item to initially align within the viewport.
final
itemPositionListener ItemPositionsListener
Provides a listenable iterable of itemPositions of items that are on screen and their locations.
final
key Key
Controls how one widget replaces another widget in the tree. [...]
final, inherited
loadingBuilder WidgetBuilder
Function used to build a loading widget
final
messageBuilder MessageBuilder
Function used to build a custom message widget
final
messageFilter bool Function(Message)
Predicate used to filter messages
final
messageHighlightColor Color
Color used while highlighting initial message
final
messageListBuilder Widget Function(BuildContext, List<Message>)
Function called when messages are fetched
final
onAttachmentTap → void Function(Message message, Attachment attachment)
Customize onTap on attachment
final
onMessageSwiped OnMessageSwiped
Called when message item gets swiped
final
onMessageTap OnMessageTap
Called when any message is tapped except a system message (use onSystemMessageTap instead)
final
onReplyTap ReplyTapCallback
final
onShowMessage ShowMessageCallback
final
onSystemMessageTap OnMessageTap
Called when system message is tapped
final
onThreadTap ThreadTapCallback
Function called when tapping on a thread By default it calls Navigator.push using the widget built using threadBuilder
final
parentMessage Message
Parent message in case of a thread
final
parentMessageBuilder ParentMessageBuilder
Function used to build a custom parent message widget
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
scrollController ItemScrollController
Controller for jumping or scrolling to an item.
final
scrollPhysics ScrollPhysics
The ScrollPhysics used by the ListView
final
showConnectionStateTile bool
final
showScrollToBottom bool
If true will show a scroll to bottom message when there are new messages and the scroll offset is not zero
final
systemMessageBuilder SystemMessageBuilder
Function used to build a custom system message widget
final
textBuilder → void Function(BuildContext context, Message message)
Customize the MessageWidget textBuilder
final
threadBuilder ThreadBuilder
Function used to build a custom thread widget
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
inherited
createState() → _MessageListViewState
Creates the mutable state for this widget at a given location in the tree. [...]
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toDiagnosticsNode({String name, DiagnosticsTreeStyle style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object. [...]
inherited
toStringDeep({String prefixLineOne = '', String prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants. [...]
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object. [...]
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
@nonVirtual, inherited