Channel class

Class that manages a specific channel.

Channel name

If an optional name argument is provided in the constructor then it will be set on extraData with a key of 'name'.

final channel = Channel(client, type, id, name: 'Channel name');
print(channel.name == channel.extraData['name']); // true

Before the channel is initialized the name can be set directly:

channel.name = 'New channel name';

To update the name after the channel has been initialized, call:

channel.updateName('Updated channel name');

This will do a partial update to update the name.

Channel image

If an optional image argument is provided in the constructor then it will be set on extraData with a key of 'image'.

final channel = Channel(client, type, id, image: 'https://getstream.io/image.png');
print(channel.image == channel.extraData['image']); // true

Before the channel is initialized the image can be set directly:

channel.image = 'https://getstream.io/new-image';

To update the image after the channel has been initialized, call:

channel.updateImage('https://getstream.io/new-image');

This will do a partial update to update the image.

Constructors

Channel(StreamChatClient _client, String _type, String? _id, {String? name, String? image, Map<String, Object?>? extraData})
Class that manages a specific channel.
Channel.fromState(StreamChatClient _client, ChannelState channelState)
Create a channel client instance from a ChannelState object.

Properties

cid String?
Channel cid.
no setter
client StreamChatClient
The main Stream chat client.
no setter
config ChannelConfig?
Channel configuration.
no setter
configStream Stream<ChannelConfig?>
Channel configuration as a stream.
no setter
cooldown int
Cooldown count
no setter
cooldownStartedAt DateTime?
Stores time at which cooldown was started
getter/setter pair
cooldownStream Stream<int>
Cooldown count as a stream
no setter
createdAt DateTime?
Channel creation date.
no setter
createdAtStream Stream<DateTime?>
Channel creation date as a stream.
no setter
createdBy User?
Channel user creator.
no setter
createdByStream Stream<User?>
Channel user creator as a stream.
no setter
deletedAt DateTime?
Channel deletion date.
no setter
deletedAtStream Stream<DateTime?>
Channel deletion date as a stream.
no setter
extraData Map<String, Object?>
Channel extra data.
getter/setter pair
extraDataStream Stream<Map<String, Object?>>
Channel extra data as a stream.
no setter
frozen bool
Channel frozen status.
no setter
frozenStream Stream<bool>
Channel frozen status as a stream.
no setter
hashCode int
The hash code for this object.
no setterinherited
id String?
Channel id.
no setter
image String?
Shortcut to get channel image.
getter/setter pair
imageStream Stream<String?>
Channel image as a stream.
no setter
initialized Future<bool>
True if this is initialized.
no setter
isDistinct bool
True if the channel is distinct.
no setter
isGroup bool
True if the channel is a group.
no setter
isMuted bool
Returns true if the channel is muted.
no setter
isMutedStream Stream<bool>
Returns true if the channel is muted, as a stream.
no setter
lastMessageAt DateTime?
Channel last message date.
no setter
lastMessageAtStream Stream<DateTime?>
Channel last message date as a stream.
no setter
memberCount int?
Channel member count.
no setter
memberCountStream Stream<int?>
Channel member count as a stream.
no setter
name String?
Shortcut to get channel name.
getter/setter pair
nameStream Stream<String?>
Channel name as a stream.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state ChannelClientState?
This client state
getter/setter pair
team String?
Channel team.
no setter
type String
Channel type.
no setter
updatedAt DateTime?
Channel updated date.
no setter
updatedAtStream Stream<DateTime?>
Channel updated date as a stream.
no setter

Methods

acceptInvite([Message? message]) Future<AcceptInviteResponse>
Accept invitation to the channel.
addMembers(List<String> memberIds, [Message? message]) Future<AddMembersResponse>
Add members to the channel.
banMember(String userID, Map<String, dynamic> options) Future<EmptyResponse>
Bans the member with given userID from the channel.
banUser(String userID, Map<String, dynamic> options) Future<EmptyResponse>
Bans the user with given userID from the channel.
cancelAttachmentUpload(String attachmentId, {String? reason}) → void
Cancels attachmentId upload request. Throws exception if the request hasn't even started yet, Already completed or Already cancelled.
create() Future<ChannelState>
Creates a new channel.
delete() Future<EmptyResponse>
Delete this channel. Messages are permanently removed.
deleteFile(String url, {CancelToken? cancelToken}) Future<EmptyResponse>
Delete a file from this channel.
deleteImage(String url, {CancelToken? cancelToken}) Future<EmptyResponse>
Delete an image from this channel.
deleteMessage(Message message, {bool? hard}) Future<EmptyResponse>
Deletes the message from the channel.
deleteReaction(Message message, Reaction reaction) Future<EmptyResponse>
Delete a reaction from this channel.
disableSlowMode() Future<PartialUpdateChannelResponse>
Disable slow mode
dispose() → void
Call this method to dispose the channel client.
enableSlowMode({required int cooldownInterval}) Future<PartialUpdateChannelResponse>
Enable slow mode
getMessagesById(List<String> messageIDs) Future<GetMessagesByIdResponse>
Retrieves a list of messages by given messageIDs.
getReactions(String messageId, {PaginationParams? pagination}) Future<QueryReactionsResponse>
List the reactions for a message in the channel.
getReplies(String parentId, {PaginationParams? options, bool preferOffline = false}) Future<QueryRepliesResponse>
List the message replies for a parent message.
hide({bool clearHistory = false}) Future<EmptyResponse>
Hides the channel from StreamChatClient.queryChannels for the user until a message is added.
inviteMembers(List<String> memberIds, [Message? message]) Future<InviteMembersResponse>
Invite members to the channel.
keyStroke([String? parentId]) Future<void>
First of the EventType.typingStart and EventType.typingStop events based on the users keystrokes. Call this on every keystroke.
markRead({String? messageId}) Future<EmptyResponse>
Mark all messages as read.
mute({Duration? expiration}) Future<EmptyResponse>
Mutes the channel.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
on([String? eventType, String? eventType2, String? eventType3, String? eventType4]) Stream<Event>
Stream of Event coming from websocket connection specific for the channel. Pass an eventType as parameter in order to filter just a type of event.
partialUpdateMessage(Message message, {Map<String, Object?>? set, List<String>? unset}) Future<UpdateMessageResponse>
Partially updates the message in this channel.
pinMessage(Message message, {Object? timeoutOrExpirationDate}) Future<UpdateMessageResponse>
Pins provided message
query({bool state = true, bool watch = false, bool presence = false, PaginationParams? messagesPagination, PaginationParams? membersPagination, PaginationParams? watchersPagination, bool preferOffline = false}) Future<ChannelState>
Query the API, get messages, members or other channel fields.
queryBannedUsers({Filter? filter, List<SortOption>? sort, PaginationParams? pagination}) Future<QueryBannedUsersResponse>
Query channel banned users.
queryMembers({Filter? filter, List<SortOption>? sort, PaginationParams? pagination}) Future<QueryMembersResponse>
Query channel members.
rejectInvite([Message? message]) Future<RejectInviteResponse>
Reject invitation to the channel.
removeMembers(List<String> memberIds, [Message? message]) Future<RemoveMembersResponse>
Remove members from the channel.
removeShadowBan(String userID) Future<EmptyResponse>
Remove the shadow ban for the user with the given userID in the channel.
retryAttachmentUpload(String messageId, String attachmentId) Future<void>
Retries the failed attachmentId upload request.
Search for a message with the given options.
sendAction(Message message, Map<String, dynamic> formData) Future<SendActionResponse>
Send action for a specific message of this channel.
sendEvent(Event event) Future<EmptyResponse>
Send an event on this channel.
sendFile(AttachmentFile file, {ProgressCallback? onSendProgress, CancelToken? cancelToken}) Future<SendFileResponse>
Send a file to this channel.
sendImage(AttachmentFile file, {ProgressCallback? onSendProgress, CancelToken? cancelToken}) Future<SendImageResponse>
Send an image to this channel.
sendMessage(Message message, {bool skipPush = false}) Future<SendMessageResponse>
Send a message to this channel.
sendReaction(Message message, String type, {int score = 1, Map<String, Object?> extraData = const {}, bool enforceUnique = false}) Future<SendReactionResponse>
Send a reaction to this channel.
shadowBan(String userID, Map<String, dynamic> options) Future<EmptyResponse>
Shadow bans the user with the given userID from the channel.
show() Future<EmptyResponse>
Removes the hidden status for the channel.
stopTyping([String? parentId]) Future<void>
Sets last typing to null and sends the typing.stop event.
stopWatching() Future<EmptyResponse>
Stop watching the channel.
toString() String
A string representation of this object.
inherited
translateMessage(String messageId, String language) Future<TranslateMessageResponse>
Translate a message by given messageId and language.
truncate({Message? message, bool? skipPush, DateTime? truncatedAt}) Future<EmptyResponse>
Removes all messages from the channel up to truncatedAt or now if truncatedAt is not provided. If skipPush is true, no push notification will be sent. Message is the system message that will be sent to the channel.
unbanMember(String userID) Future<EmptyResponse>
Remove the ban for the member with given userID in the channel.
unbanUser(String userID) Future<EmptyResponse>
Remove the ban for the user with given userID in the channel.
unmute() Future<EmptyResponse>
Unmute the channel.
unpinMessage(Message message) Future<UpdateMessageResponse>
Unpins provided message.
update(Map<String, Object?> channelData, [Message? updateMessage]) Future<UpdateChannelResponse>
Update the channel custom data. This replaces all of the channel data with the given channelData.
updateImage(String image) Future<PartialUpdateChannelResponse>
Update the channel's image.
updateMessage(Message message) Future<UpdateMessageResponse>
Updates the message in this channel.
updateName(String name) Future<PartialUpdateChannelResponse>
Update the channel's name.
updatePartial({Map<String, Object?>? set, List<String>? unset}) Future<PartialUpdateChannelResponse>
A partial update can be used to set and unset specific custom data fields when it is necessary to retain additional custom data fields on the object.
watch() Future<ChannelState>
Loads the initial channel state and watches for changes.

Operators

operator ==(Object other) bool
The equality operator.
inherited