Channel class

Class that manages a specific channel.

Channel name

If an name is provided it will be set on extraData with a key of 'name'.

For example:

final user = User(id: 'id', name: 'Sahil Kumar');
print(user.name == user.extraData['name']); // true

Channel image

If an image is provided it will be set on extraData with a key of 'image'.

For example:

final user = User(id: 'id', image: 'https://getstream.io/image.png');
print(user.image == user.extraData['image']); // true
Available extensions

Constructors

Channel.new(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

canBanChannelMembers bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can ban channel members.
no setter
canCastPollVote bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can vote in a poll.
no setter
canCreateAttachment bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can attach files to messages.
no setter
canDeleteAnyMessage bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can delete any message from the channel.
no setter
canDeleteChannel bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can delete channel.
no setter
canDeleteOwnMessage bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can delete own messages from the channel.
no setter
canFlagMessage bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can flag a message.
no setter
canFreezeChannel bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can freeze or unfreeze channel.
no setter
canJoinChannel bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can join channel (add own membership).
no setter
canLeaveChannel bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can leave channel (remove own membership).
no setter
canMuteChannel bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can mute a channel.
no setter
canPinMessage bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can pin a message.
no setter
canQueryPollVotes bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can query poll votes.
no setter
canQuoteMessage bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can quote a message.
no setter
canReceiveConnectEvents bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user has connect events capability.
no setter
canReceiveReadEvents bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user has read events capability.
no setter
canSearchMessages bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can use message search.
no setter
canSendCustomEvents bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can send custom events.
no setter

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can attach links to messages.
no setter
canSendMessage bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can send a message to this channel.
no setter
canSendPoll bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can create a poll.
no setter
canSendReaction bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can send reactions.
no setter
canSendReply bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can send a reply to this channel.
no setter
canSendRestrictedVisibilityMessage bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can send a message with restricted visibility.
no setter
canSendTypingEvents bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can send typing events.
no setter
canSetChannelCooldown bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can enable or disable slow mode.
no setter
canSkipSlowMode bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user is allowed to post messages as usual even if the channel is in slow mode.
no setter
canUpdateAnyMessage bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can update any message in the channel.
no setter
canUpdateChannel bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can update channel data.
no setter
canUpdateChannelMembers bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can update channel members.
no setter
canUpdateOwnMessage bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can update own messages in the channel.
no setter
canUpdateThread bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can update thread data.
no setter
canUploadFile bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can upload message attachments.
no setter
canUseTypingEvents bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if the current user can send and receive typing events.
no setter
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
no setter
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
currentUserLastMessageAt DateTime?
The date of the last message sent by the current user.
no setter
currentUserLastMessageAtStream Stream<DateTime?>
The date of the last message sent by the current user as a stream.
no setter
deletedAt DateTime?
Channel deletion date.
no setter
deletedAtStream Stream<DateTime?>
Channel deletion date as a stream.
no setter
disabled bool
Channel disabled status.
no setter
disabledStream Stream<bool>
Channel disabled status 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
hidden bool
Channel hidden status.
no setter
hiddenStream Stream<bool>
Channel hidden status as a stream.
no setter
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
isArchived bool
Channel archived status. Status is specific to the current user.
no setter
isArchivedStream Stream<bool>
Channel archived status as a stream. Status is specific to the current user.
no setter
isDistinct bool
True if the channel is distinct.
no setter
isGroup bool
True if the channel is a group.
no setter
isInSlowMode bool

Available on Channel, provided by the ChannelCapabilityCheck extension

True, if channel slow mode is active.
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
isPinned bool
Channel pinned status. Status is specific to the current user.
no setter
isPinnedStream Stream<bool>
Channel pinned status as a stream. Status is specific to the current user.
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
membership Member?
Relationship of the current user to this channel.
no setter
membershipStream Stream<Member?>
Relationship of the current user to this channel 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
ownCapabilities List<ChannelCapability>
List of user permissions on this channel
no setter
ownCapabilitiesStream Stream<List<ChannelCapability>>
List of user permissions on this channel
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
truncatedAt DateTime?
The last date at which the channel got truncated.
no setter
truncatedAtStream Stream<DateTime?>
The last date at which the channel got truncated as a stream.
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, bool hideHistory = false}) Future<AddMembersResponse>
Add members to the channel.
addPollAnswer(Message message, Poll poll, {required String answerText}) Future<CastPollVoteResponse>
Add a new answer to the given poll.
archive() Future<Member?>
Archives the channel.
banMember(String userID, Map<String, dynamic> options) Future<EmptyResponse>
Bans the member 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.
castPollVote(Message message, Poll poll, PollOption option) Future<CastPollVoteResponse>
Cast a vote on the given poll with the given option.
closePoll(Poll poll) Future<UpdatePollResponse>
Close the given poll.
create() Future<ChannelState>
Creates a new channel.
createDraft(DraftMessage draft) Future<CreateDraftResponse>
Creates or updates a new draft for this channel.
createPollOption(Poll poll, PollOption option) Future<CreatePollOptionResponse>
Create a new poll option for the given poll.
createReminder(String messageId, {DateTime? remindAt}) Future<CreateReminderResponse>
Create a reminder for the given messageId.
delete() Future<EmptyResponse>
Delete this channel. Messages are permanently removed.
deleteDraft({String? parentId}) Future<EmptyResponse>
Deletes the draft for this channel.
deleteFile(String url, {CancelToken? cancelToken, Map<String, Object?>? extraData}) Future<EmptyResponse>
Delete a file from this channel.
deleteImage(String url, {CancelToken? cancelToken, Map<String, Object?>? extraData}) Future<EmptyResponse>
Delete an image from this channel.
deleteMessage(Message message, {bool hard = false}) Future<EmptyResponse>
Deletes the message from the channel.
deletePoll(Poll poll) Future<EmptyResponse>
Deletes the given poll from this channel.
deleteReaction(Message message, Reaction reaction) Future<EmptyResponse>
Delete a reaction from this channel.
deleteReminder(String messageId) Future<EmptyResponse>
Remove the reminder for the given messageId.
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
getDraft({String? parentId}) Future<GetDraftResponse>
Retrieves the draft for this channel.
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.
getRemainingCooldown() int
Remaining cooldown duration in seconds for 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>
Sends the Event.typingStart event and schedules a timer to invoke the Event.typingStop event.
markRead({String? messageId}) Future<EmptyResponse>
Mark all messages as read.
markThreadRead(String threadId) Future<EmptyResponse>
Mark the thread with threadId in the channel as read.
markThreadUnread(String threadId) Future<EmptyResponse>
Mark the thread with threadId in the channel as unread.
markUnread(String messageId) Future<EmptyResponse>
Mark message as unread.
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, bool skipEnrichUrl = false}) Future<UpdateMessageResponse>
Partially updates the message in this channel.
pin() Future<Member>
Pins the channel for the current user.
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, SortOrder<BannedUser>? sort, PaginationParams? pagination}) Future<QueryBannedUsersResponse>
Query channel banned users.
queryMembers({Filter? filter, SortOrder<Member>? sort, PaginationParams? pagination}) Future<QueryMembersResponse>
Query channel members.
queryPollVotes(String pollId, {Filter? filter, SortOrder<PollVote>? sort, PaginationParams pagination = const PaginationParams()}) Future<QueryPollVotesResponse>
Query the poll votes for the given pollId with the given filter and sort options.
rejectInvite([Message? message]) Future<RejectInviteResponse>
Reject invitation to the channel.
removeMembers(List<String> memberIds, {Message? message}) Future<RemoveMembersResponse>
Remove members from the channel.
removePollVote(Message message, Poll poll, PollVote vote) Future<RemovePollVoteResponse>
Remove a vote on the given poll with the given vote.
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.
retryMessage(Message message) Future<Object>
Retry the operation on the message based on the failed state.
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, Map<String, Object?>? extraData}) Future<SendFileResponse>
Send a file to this channel.
sendImage(AttachmentFile file, {ProgressCallback? onSendProgress, CancelToken? cancelToken, Map<String, Object?>? extraData}) Future<SendImageResponse>
Send an image to this channel.
sendMessage(Message message, {bool skipPush = false, bool skipEnrichUrl = false}) Future<SendMessageResponse>
Send a message to this channel.
sendPoll(Poll poll, {String messageText = ''}) Future<SendMessageResponse>
Send a message with a poll 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.
startTyping([String? parentId]) Future<void>
Sends the EventType.typingStart event.
stopAIResponse() Future<EmptyResponse>
Sends an event to stop AI response generation, leaving the message in its current state.
stopTyping([String? parentId]) Future<void>
Sends the EventType.typingStop 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.
unarchive() Future<Member?>
Unarchives the channel for the current user.
unbanMember(String userID) Future<EmptyResponse>
Remove the ban for the member with given userID in the channel.
unmute() Future<EmptyResponse>
Unmute the channel.
unpin() Future<Member?>
Unpins 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, {bool skipEnrichUrl = false}) 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.
updatePoll(Poll poll) Future<UpdatePollResponse>
Updates the poll in this channel.
updateReminder(String messageId, {DateTime? remindAt}) Future<UpdateReminderResponse>
Update an existing reminder with the given reminderId.
watch({bool presence = false, PaginationParams? messagesPagination, PaginationParams? membersPagination, PaginationParams? watchersPagination}) Future<ChannelState>
Loads the initial channel state and watches for changes.

Operators

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