ChatCubit class

Constructors

ChatCubit(ChatApi _chatApi, {required int roomId, required int myId, int defaultChatPageSize = kDefaultPageSize})

Properties

defaultChatPageSize int
The default page size for pagination
final
hashCode int
The hash code for this object.
no setterinherited
isClosed bool
Whether the bloc is closed.
no setterinherited
myId int
The current logged in user's id
final
roomId int
The Room id
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state ChatState
The current state.
no setterinherited
stream Stream<ChatState>
The current stream of states.
no setterinherited

Methods

addError(Object error, [StackTrace? stackTrace]) → void
Reports an error which triggers onError with an optional StackTrace.
inherited
addMessage(ChatMessage message) → void
Add a Message to messages
close() Future<void>
Closes the instance. This method should be called when the instance is no longer needed. Once close is called, the instance can no longer be used.
inherited
emit(ChatState state) → void
Updates the state to the provided state. emit does nothing if the state being emitted is equal to the current state.
inherited
loadData() Future<void>
Loads the Room, RoomUsers and Message as well, this needs to be called at the start of the chat to load the initial data
loadMoreMessages({required int roomId, bool reload = false}) Future<void>
Load messages, automatically load more messages for pagination
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onChange(Change<ChatState> change) → void
Called whenever a change occurs with the given change. A change occurs when a new state is emitted. onChange is called before the state of the cubit is updated. onChange is a great spot to add logging/analytics for a specific cubit.
inherited
onError(Object error, StackTrace stackTrace) → void
Called whenever an error occurs and notifies BlocObserver.onError.
inherited
sendTextMessage({required String text}) Future<ChatMessage?>
Send text message
startLoading() → void
Mark messages as seen, need to provide a roomId and a list of messageIds React to a message with a reactionBody Currently one user can react once, so if the user already reacted to a message the reaction will be removed instead If the user did not react to the message yet, the reaction will be added Private method to add a reaction to a message Dispatches loading state, helpful for displaying loading indicator
stopLoading() → void
Dispatches loading state, helpful for displaying loading indicator
toString() String
A string representation of this object.
inherited

Operators

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