ChannelListView class
It shows the list of current channels.
class ChannelListPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ChannelListView(
filter: {
'members': {
'\$in': [StreamChat.of(context).user.id],
}
},
sort: [SortOption('last_message_at')],
pagination: PaginationParams(
limit: 20,
),
channelWidget: ChannelPage(),
),
);
}
}
Make sure to have a StreamChat 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
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ChannelListView
- Annotations
-
- @Deprecated("Use 'StreamChannelListView' instead")
Constructors
-
ChannelListView({Key? key, Filter? filter, List<
SortOption< ? sort, bool state = true, bool watch = true, bool presence = false, int? memberLimit, int? messageLimit, @Deprecated("'pagination' is deprecated and shouldn't be used. " "This property is no longer used, Please use 'limit' instead") PaginationParams? pagination, int? limit, ChannelTapCallback? onChannelTap, dynamic onChannelLongPress(Channel)?, Widget? channelWidget, ChannelPreviewBuilder? channelPreviewBuilder, dynamic separatorBuilder(BuildContext, int)?, dynamic onImageTap(Channel)?, VoidCallback? onStartChatPressed, bool swipeToAction = false, bool pullToRefresh = true, int crossAxisCount = 1, EdgeInsetsGeometry? padding, List<ChannelModel> >Channel> selectedChannels = const [], ViewInfoCallback? onViewInfoTap, ErrorBuilder? errorBuilder, WidgetBuilder? emptyBuilder, WidgetBuilder? loadingBuilder, dynamic listBuilder(BuildContext, List<Channel> )?, ChannelInfoCallback? onMoreDetailsPressed, ChannelInfoCallback? onDeletePressed, List<SwipeAction> ? swipeActions, ChannelListController? channelListController}) - Instantiate a new ChannelListView
Properties
- channelListController → ChannelListController?
-
A ChannelListController allows reloading and pagination.
Use ChannelListController.loadData and
ChannelListController.paginateData respectively for reloading and
pagination.
final
- channelPreviewBuilder → ChannelPreviewBuilder?
-
Builder used to create a custom channel preview
final
- channelWidget → Widget?
-
Widget used when opening a channel
final
- crossAxisCount → int
-
The number of children in the cross axis.
final
- emptyBuilder → WidgetBuilder?
-
The builder used when the channel list is empty.
final
- errorBuilder → ErrorBuilder?
-
The builder that will be used in case of error
final
- filter → Filter?
-
The query filters to use.
You can query on any of the custom fields you've defined on the Channel.
You can also filter other built-in channel fields.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- limit → int
-
The amount of channels requested per API call.
final
-
listBuilder
→ (dynamic Function(BuildContext, List<
Channel> )?) -
The builder which is used when list of channels loads
final
- loadingBuilder → WidgetBuilder?
-
The builder that will be used in case of loading
final
- memberLimit → int?
-
Number of members to fetch in each channel
final
- messageLimit → int?
-
Number of messages to fetch in each channel
final
- onChannelLongPress → (dynamic Function(Channel)?)
-
Function called when long pressing on a channel
final
- onChannelTap → ChannelTapCallback?
-
Function called when tapping on a channel
By default it calls Navigator.push building a MaterialPageRoute
with the widget channelWidget as child.
final
- onDeletePressed → ChannelInfoCallback?
-
Callback used when the delete slidable option is pressed
final
- onImageTap → (dynamic Function(Channel)?)
-
The function called when the image is tapped
final
- onMoreDetailsPressed → ChannelInfoCallback?
-
Callback used when the more details slidable option is pressed
final
- onStartChatPressed → VoidCallback?
-
Callback used in the default empty list widget
final
- onViewInfoTap → ViewInfoCallback?
-
Callback for when 'View Info' is tapped
final
- padding → EdgeInsetsGeometry?
-
The amount of space by which to inset the children.
final
- pagination → PaginationParams?
-
Pagination parameters
limit: the number of channels to return (max is 30)
offset: the offset (max is 1000)
message_limit: how many messages should be included to each channel
final
- presence → bool
-
If true you’ll receive user presence updates via the websocket events
final
- pullToRefresh → bool
-
Set it to false to disable the pull-to-refresh widget
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
selectedChannels
→ List<
Channel> -
List of selected channels which are displayed differently
final
- separatorBuilder → (dynamic Function(BuildContext, int)?)
-
Builder used to create a custom item separator
final
-
sort
→ List<
SortOption< ?ChannelModel> > -
The sorting used for the channels matching the filters.
Sorting is based on field and direction, multiple sorting options
can be provided.
You can sort based on last_updated, last_message_at, updated_at,
created_at or member_count.
Direction can be ascending or descending.
final
- state → bool
-
If true returns the Channel state
final
-
swipeActions
→ List<
SwipeAction> ? -
List of actions for slidable
final
- swipeToAction → bool
-
If true a default swipe to action behaviour will be added to this widget
final
- watch → bool
-
If true listen to changes to this Channel in real time.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _ChannelListViewState -
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.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent 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.
inherited