Channel class Null safety

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

Methods

acceptInvite([Message? message]) Future<AcceptInviteResponse>
Accept invitation to the channel.
addMembers(List<String> memberIds, [Message? message]) Future<AddMembersResponse>
Add members to 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 non-existent 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. [...]
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, {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() Future<EmptyResponse>
Removes all messages from 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