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

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
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
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
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<String>
List of user permissions on this channel
no setter
ownCapabilitiesStream Stream<List<String>>
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.
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.
create() Future<ChannelState>
Creates a new channel.
delete() Future<EmptyResponse>
Delete this channel. Messages are permanently removed.
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.
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>
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.
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.
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.
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.
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.
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.
unbanMember(String userID) Future<EmptyResponse>
Remove the ban for the member 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, {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.
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