Enhance model and service documentation with detailed comments and descriptions
- Updated Group, Trip, User, and other model classes to include comprehensive documentation for better understanding and maintainability. - Improved error handling and logging in services, including AuthService, ErrorService, and StorageService. - Added validation and business logic explanations in ExpenseService and TripService. - Refactored method comments to follow a consistent format across the codebase. - Translated error messages and comments from French to English for consistency.
This commit is contained in:
@@ -1,3 +1,44 @@
|
||||
/// A BLoC (Business Logic Component) that manages message-related operations for group chats.
|
||||
///
|
||||
/// This bloc handles all messaging functionality including sending, updating, deleting messages,
|
||||
/// and managing reactions. It provides real-time updates through streams and manages the
|
||||
/// relationship between users and group conversations.
|
||||
///
|
||||
/// The bloc processes these main events:
|
||||
/// - [LoadMessages]: Loads messages for a group with real-time updates
|
||||
/// - [SendMessage]: Sends a new message to a group chat
|
||||
/// - [DeleteMessage]: Deletes a message from the chat
|
||||
/// - [UpdateMessage]: Updates/edits an existing message
|
||||
/// - [ReactToMessage]: Adds an emoji reaction to a message
|
||||
/// - [RemoveReaction]: Removes a user's reaction from a message
|
||||
///
|
||||
/// Dependencies:
|
||||
/// - [MessageService]: Service for message operations and business logic
|
||||
/// - [MessageRepository]: Repository for message data operations
|
||||
///
|
||||
/// Example usage:
|
||||
/// ```dart
|
||||
/// final messageBloc = MessageBloc();
|
||||
///
|
||||
/// // Load messages for a group
|
||||
/// messageBloc.add(LoadMessages('groupId123'));
|
||||
///
|
||||
/// // Send a message
|
||||
/// messageBloc.add(SendMessage(
|
||||
/// groupId: 'groupId123',
|
||||
/// text: 'Hello everyone!',
|
||||
/// senderId: 'userId123',
|
||||
/// senderName: 'John Doe',
|
||||
/// ));
|
||||
///
|
||||
/// // React to a message
|
||||
/// messageBloc.add(ReactToMessage(
|
||||
/// groupId: 'groupId123',
|
||||
/// messageId: 'msgId456',
|
||||
/// userId: 'userId123',
|
||||
/// reaction: '👍',
|
||||
/// ));
|
||||
/// ```
|
||||
import 'dart:async';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../models/message.dart';
|
||||
@@ -6,10 +47,22 @@ import '../../repositories/message_repository.dart';
|
||||
import 'message_event.dart';
|
||||
import 'message_state.dart';
|
||||
|
||||
/// BLoC that manages message-related operations and real-time chat state.
|
||||
class MessageBloc extends Bloc<MessageEvent, MessageState> {
|
||||
/// Service for message operations and business logic
|
||||
final MessageService _messageService;
|
||||
|
||||
/// Subscription to message stream for real-time updates
|
||||
StreamSubscription<List<Message>>? _messagesSubscription;
|
||||
|
||||
/// Constructor for MessageBloc.
|
||||
///
|
||||
/// Initializes the bloc with an optional message service. If no service is provided,
|
||||
/// creates a default MessageService with MessageRepository. Sets up event handlers
|
||||
/// for all message-related operations.
|
||||
///
|
||||
/// Args:
|
||||
/// [messageService]: Optional service for message operations (auto-created if null)
|
||||
MessageBloc({MessageService? messageService})
|
||||
: _messageService = messageService ?? MessageService(
|
||||
messageRepository: MessageRepository(),
|
||||
@@ -24,6 +77,14 @@ class MessageBloc extends Bloc<MessageEvent, MessageState> {
|
||||
on<_MessagesUpdated>(_onMessagesUpdated);
|
||||
}
|
||||
|
||||
/// Handles [LoadMessages] events.
|
||||
///
|
||||
/// Loads messages for a specific group with real-time updates via stream subscription.
|
||||
/// Cancels any existing subscription before creating a new one to prevent memory leaks.
|
||||
///
|
||||
/// Args:
|
||||
/// [event]: The LoadMessages event containing the group ID
|
||||
/// [emit]: State emitter function
|
||||
Future<void> _onLoadMessages(
|
||||
LoadMessages event,
|
||||
Emitter<MessageState> emit,
|
||||
@@ -39,11 +100,19 @@ class MessageBloc extends Bloc<MessageEvent, MessageState> {
|
||||
add(_MessagesUpdated(messages: messages, groupId: event.groupId));
|
||||
},
|
||||
onError: (error) {
|
||||
add(_MessagesError('Erreur lors du chargement des messages: $error'));
|
||||
add(_MessagesError('Error loading messages: $error'));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Handles [_MessagesUpdated] events.
|
||||
///
|
||||
/// Processes real-time updates from the message stream, emitting the
|
||||
/// updated message list with the associated group ID.
|
||||
///
|
||||
/// Args:
|
||||
/// [event]: The _MessagesUpdated event containing messages and group ID
|
||||
/// [emit]: State emitter function
|
||||
void _onMessagesUpdated(
|
||||
_MessagesUpdated event,
|
||||
Emitter<MessageState> emit,
|
||||
@@ -51,12 +120,20 @@ class MessageBloc extends Bloc<MessageEvent, MessageState> {
|
||||
emit(MessagesLoaded(messages: event.messages, groupId: event.groupId));
|
||||
}
|
||||
|
||||
/// Handles [SendMessage] events.
|
||||
///
|
||||
/// Sends a new message to a group chat. The stream subscription will
|
||||
/// automatically update the UI with the new message, so no state is emitted here.
|
||||
///
|
||||
/// Args:
|
||||
/// [event]: The SendMessage event containing message details
|
||||
/// [emit]: State emitter function
|
||||
Future<void> _onSendMessage(
|
||||
SendMessage event,
|
||||
Emitter<MessageState> emit,
|
||||
) async {
|
||||
try {
|
||||
// Juste effectuer l'action, le stream mettra à jour
|
||||
// Just perform the action, the stream will update
|
||||
await _messageService.sendMessage(
|
||||
groupId: event.groupId,
|
||||
text: event.text,
|
||||
@@ -64,50 +141,74 @@ class MessageBloc extends Bloc<MessageEvent, MessageState> {
|
||||
senderName: event.senderName,
|
||||
);
|
||||
} catch (e) {
|
||||
emit(MessageError('Erreur lors de l\'envoi du message: $e'));
|
||||
emit(MessageError('Error sending message: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles [DeleteMessage] events.
|
||||
///
|
||||
/// Deletes a message from the group chat. The Firestore stream will
|
||||
/// automatically update the UI, so no state is emitted here unless there's an error.
|
||||
///
|
||||
/// Args:
|
||||
/// [event]: The DeleteMessage event containing group ID and message ID
|
||||
/// [emit]: State emitter function
|
||||
Future<void> _onDeleteMessage(
|
||||
DeleteMessage event,
|
||||
Emitter<MessageState> emit,
|
||||
) async {
|
||||
try {
|
||||
// Ne pas émettre d'état, juste effectuer l'action
|
||||
// Le stream Firestore mettra à jour automatiquement
|
||||
// Don't emit state, just perform the action
|
||||
// The Firestore stream will update automatically
|
||||
await _messageService.deleteMessage(
|
||||
groupId: event.groupId,
|
||||
messageId: event.messageId,
|
||||
);
|
||||
} catch (e) {
|
||||
emit(MessageError('Erreur lors de la suppression du message: $e'));
|
||||
emit(MessageError('Error deleting message: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles [UpdateMessage] events.
|
||||
///
|
||||
/// Updates/edits an existing message in the group chat. The Firestore stream will
|
||||
/// automatically update the UI with the edited message, so no state is emitted here.
|
||||
///
|
||||
/// Args:
|
||||
/// [event]: The UpdateMessage event containing message ID and new text
|
||||
/// [emit]: State emitter function
|
||||
Future<void> _onUpdateMessage(
|
||||
UpdateMessage event,
|
||||
Emitter<MessageState> emit,
|
||||
) async {
|
||||
try {
|
||||
// Ne pas émettre d'état, juste effectuer l'action
|
||||
// Le stream Firestore mettra à jour automatiquement
|
||||
// Don't emit state, just perform the action
|
||||
// The Firestore stream will update automatically
|
||||
await _messageService.updateMessage(
|
||||
groupId: event.groupId,
|
||||
messageId: event.messageId,
|
||||
newText: event.newText,
|
||||
);
|
||||
} catch (e) {
|
||||
emit(MessageError('Erreur lors de la modification du message: $e'));
|
||||
emit(MessageError('Error updating message: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles [ReactToMessage] events.
|
||||
///
|
||||
/// Adds an emoji reaction to a message. The Firestore stream will
|
||||
/// automatically update the UI with the new reaction, so no state is emitted here.
|
||||
///
|
||||
/// Args:
|
||||
/// [event]: The ReactToMessage event containing message ID, user ID, and reaction
|
||||
/// [emit]: State emitter function
|
||||
Future<void> _onReactToMessage(
|
||||
ReactToMessage event,
|
||||
Emitter<MessageState> emit,
|
||||
) async {
|
||||
try {
|
||||
// Ne pas émettre d'état, juste effectuer l'action
|
||||
// Le stream Firestore mettra à jour automatiquement
|
||||
// Don't emit state, just perform the action
|
||||
// The Firestore stream will update automatically
|
||||
await _messageService.reactToMessage(
|
||||
groupId: event.groupId,
|
||||
messageId: event.messageId,
|
||||
@@ -115,27 +216,39 @@ class MessageBloc extends Bloc<MessageEvent, MessageState> {
|
||||
reaction: event.reaction,
|
||||
);
|
||||
} catch (e) {
|
||||
emit(MessageError('Erreur lors de l\'ajout de la réaction: $e'));
|
||||
emit(MessageError('Error adding reaction: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles [RemoveReaction] events.
|
||||
///
|
||||
/// Removes a user's reaction from a message. The Firestore stream will
|
||||
/// automatically update the UI with the removed reaction, so no state is emitted here.
|
||||
///
|
||||
/// Args:
|
||||
/// [event]: The RemoveReaction event containing message ID and user ID
|
||||
/// [emit]: State emitter function
|
||||
Future<void> _onRemoveReaction(
|
||||
RemoveReaction event,
|
||||
Emitter<MessageState> emit,
|
||||
) async {
|
||||
try {
|
||||
// Ne pas émettre d'état, juste effectuer l'action
|
||||
// Le stream Firestore mettra à jour automatiquement
|
||||
// Don't emit state, just perform the action
|
||||
// The Firestore stream will update automatically
|
||||
await _messageService.removeReaction(
|
||||
groupId: event.groupId,
|
||||
messageId: event.messageId,
|
||||
userId: event.userId,
|
||||
);
|
||||
} catch (e) {
|
||||
emit(MessageError('Erreur lors de la suppression de la réaction: $e'));
|
||||
emit(MessageError('Error removing reaction: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
/// Cleans up resources when the bloc is closed.
|
||||
///
|
||||
/// Cancels the message stream subscription to prevent memory leaks
|
||||
/// and ensure proper disposal of resources.
|
||||
@override
|
||||
Future<void> close() {
|
||||
_messagesSubscription?.cancel();
|
||||
@@ -143,11 +256,22 @@ class MessageBloc extends Bloc<MessageEvent, MessageState> {
|
||||
}
|
||||
}
|
||||
|
||||
// Events internes
|
||||
/// Private event for handling real-time message updates from streams.
|
||||
///
|
||||
/// This internal event is used to process updates from the message stream
|
||||
/// subscription and emit appropriate states based on the received data.
|
||||
class _MessagesUpdated extends MessageEvent {
|
||||
/// List of messages received from the stream
|
||||
final List<Message> messages;
|
||||
|
||||
/// Group ID associated with the messages
|
||||
final String groupId;
|
||||
|
||||
/// Creates a _MessagesUpdated event.
|
||||
///
|
||||
/// Args:
|
||||
/// [messages]: List of messages from the stream update
|
||||
/// [groupId]: ID of the group these messages belong to
|
||||
const _MessagesUpdated({
|
||||
required this.messages,
|
||||
required this.groupId,
|
||||
@@ -157,9 +281,18 @@ class _MessagesUpdated extends MessageEvent {
|
||||
List<Object?> get props => [messages, groupId];
|
||||
}
|
||||
|
||||
/// Private event for handling message stream errors.
|
||||
///
|
||||
/// This internal event is used to process errors from the message stream
|
||||
/// subscription and emit appropriate error states.
|
||||
class _MessagesError extends MessageEvent {
|
||||
/// Error message from the stream
|
||||
final String error;
|
||||
|
||||
/// Creates a _MessagesError event.
|
||||
///
|
||||
/// Args:
|
||||
/// [error]: Error message from the stream failure
|
||||
const _MessagesError(this.error);
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
/// Events for message-related operations in the MessageBloc.
|
||||
///
|
||||
/// This file defines all possible events that can be dispatched to the MessageBloc
|
||||
/// to trigger message-related state changes and operations such as loading messages,
|
||||
/// sending messages, managing reactions, and performing CRUD operations on chat messages.
|
||||
///
|
||||
/// Event Categories:
|
||||
/// - **Loading Events**: LoadMessages
|
||||
/// - **Message Operations**: SendMessage, DeleteMessage, UpdateMessage
|
||||
/// - **Reaction Management**: ReactToMessage, RemoveReaction
|
||||
///
|
||||
/// All events support real-time group chat functionality with features like
|
||||
/// message editing, deletion, and emoji reactions.
|
||||
///
|
||||
/// All events extend [MessageEvent] and implement [Equatable] for proper
|
||||
/// equality comparison in the BLoC pattern.
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Base class for all message-related events.
|
||||
///
|
||||
/// All message events must extend this class and implement the [props] getter
|
||||
/// for proper equality comparison in the BLoC pattern.
|
||||
abstract class MessageEvent extends Equatable {
|
||||
const MessageEvent();
|
||||
|
||||
@@ -7,21 +27,59 @@ abstract class MessageEvent extends Equatable {
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
/// Event to load messages for a specific group with real-time updates.
|
||||
///
|
||||
/// This event initializes the message stream for a group, providing real-time
|
||||
/// updates as new messages are sent, edited, or deleted. The stream will
|
||||
/// continue until the bloc is closed or a new LoadMessages event is dispatched.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The unique identifier of the group whose messages should be loaded
|
||||
class LoadMessages extends MessageEvent {
|
||||
/// The unique identifier of the group
|
||||
final String groupId;
|
||||
|
||||
/// Creates a LoadMessages event.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The group ID to load messages for
|
||||
const LoadMessages(this.groupId);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [groupId];
|
||||
}
|
||||
|
||||
/// Event to send a new message to a group chat.
|
||||
///
|
||||
/// This event creates and sends a new message to the specified group.
|
||||
/// The message will be immediately visible to all group members through
|
||||
/// the real-time message stream.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The unique identifier of the target group
|
||||
/// [text]: The content of the message to send
|
||||
/// [senderId]: The unique identifier of the user sending the message
|
||||
/// [senderName]: The display name of the user sending the message
|
||||
class SendMessage extends MessageEvent {
|
||||
/// The unique identifier of the group
|
||||
final String groupId;
|
||||
|
||||
/// The content of the message
|
||||
final String text;
|
||||
|
||||
/// The unique identifier of the sender
|
||||
final String senderId;
|
||||
|
||||
/// The display name of the sender
|
||||
final String senderName;
|
||||
|
||||
/// Creates a SendMessage event.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The target group ID
|
||||
/// [text]: The message content
|
||||
/// [senderId]: The sender's user ID
|
||||
/// [senderName]: The sender's display name
|
||||
const SendMessage({
|
||||
required this.groupId,
|
||||
required this.text,
|
||||
@@ -33,10 +91,27 @@ class SendMessage extends MessageEvent {
|
||||
List<Object?> get props => [groupId, text, senderId, senderName];
|
||||
}
|
||||
|
||||
/// Event to delete a message from the group chat.
|
||||
///
|
||||
/// This event permanently removes a message from the chat. The deletion
|
||||
/// will be immediately reflected for all group members through the
|
||||
/// real-time message stream. This action cannot be undone.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The unique identifier of the group containing the message
|
||||
/// [messageId]: The unique identifier of the message to delete
|
||||
class DeleteMessage extends MessageEvent {
|
||||
/// The unique identifier of the group
|
||||
final String groupId;
|
||||
|
||||
/// The unique identifier of the message to delete
|
||||
final String messageId;
|
||||
|
||||
/// Creates a DeleteMessage event.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The group ID containing the message
|
||||
/// [messageId]: The message ID to delete
|
||||
const DeleteMessage({
|
||||
required this.groupId,
|
||||
required this.messageId,
|
||||
@@ -46,11 +121,32 @@ class DeleteMessage extends MessageEvent {
|
||||
List<Object?> get props => [groupId, messageId];
|
||||
}
|
||||
|
||||
/// Event to update/edit an existing message in the group chat.
|
||||
///
|
||||
/// This event allows users to modify the content of a previously sent message.
|
||||
/// The updated message will be immediately visible to all group members
|
||||
/// through the real-time message stream, typically with an "edited" indicator.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The unique identifier of the group containing the message
|
||||
/// [messageId]: The unique identifier of the message to update
|
||||
/// [newText]: The new content for the message
|
||||
class UpdateMessage extends MessageEvent {
|
||||
/// The unique identifier of the group
|
||||
final String groupId;
|
||||
|
||||
/// The unique identifier of the message to update
|
||||
final String messageId;
|
||||
|
||||
/// The new content for the message
|
||||
final String newText;
|
||||
|
||||
/// Creates an UpdateMessage event.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The group ID containing the message
|
||||
/// [messageId]: The message ID to update
|
||||
/// [newText]: The new message content
|
||||
const UpdateMessage({
|
||||
required this.groupId,
|
||||
required this.messageId,
|
||||
@@ -61,12 +157,37 @@ class UpdateMessage extends MessageEvent {
|
||||
List<Object?> get props => [groupId, messageId, newText];
|
||||
}
|
||||
|
||||
/// Event to add an emoji reaction to a message.
|
||||
///
|
||||
/// This event allows users to react to messages with emojis, providing
|
||||
/// a quick way to express emotions or acknowledgment without sending
|
||||
/// a full message. The reaction will be immediately visible to all group members.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The unique identifier of the group containing the message
|
||||
/// [messageId]: The unique identifier of the message to react to
|
||||
/// [userId]: The unique identifier of the user adding the reaction
|
||||
/// [reaction]: The emoji or reaction string to add
|
||||
class ReactToMessage extends MessageEvent {
|
||||
/// The unique identifier of the group
|
||||
final String groupId;
|
||||
|
||||
/// The unique identifier of the message
|
||||
final String messageId;
|
||||
|
||||
/// The unique identifier of the user adding the reaction
|
||||
final String userId;
|
||||
|
||||
/// The emoji or reaction string
|
||||
final String reaction;
|
||||
|
||||
/// Creates a ReactToMessage event.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The group ID containing the message
|
||||
/// [messageId]: The message ID to react to
|
||||
/// [userId]: The user ID adding the reaction
|
||||
/// [reaction]: The emoji/reaction to add
|
||||
const ReactToMessage({
|
||||
required this.groupId,
|
||||
required this.messageId,
|
||||
@@ -78,11 +199,32 @@ class ReactToMessage extends MessageEvent {
|
||||
List<Object?> get props => [groupId, messageId, userId, reaction];
|
||||
}
|
||||
|
||||
/// Event to remove a user's reaction from a message.
|
||||
///
|
||||
/// This event removes a previously added emoji reaction from a message.
|
||||
/// Only the user who added the reaction can remove it. The removal will
|
||||
/// be immediately reflected for all group members through the real-time stream.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The unique identifier of the group containing the message
|
||||
/// [messageId]: The unique identifier of the message with the reaction
|
||||
/// [userId]: The unique identifier of the user removing their reaction
|
||||
class RemoveReaction extends MessageEvent {
|
||||
/// The unique identifier of the group
|
||||
final String groupId;
|
||||
|
||||
/// The unique identifier of the message
|
||||
final String messageId;
|
||||
|
||||
/// The unique identifier of the user removing the reaction
|
||||
final String userId;
|
||||
|
||||
/// Creates a RemoveReaction event.
|
||||
///
|
||||
/// Args:
|
||||
/// [groupId]: The group ID containing the message
|
||||
/// [messageId]: The message ID with the reaction
|
||||
/// [userId]: The user ID removing the reaction
|
||||
const RemoveReaction({
|
||||
required this.groupId,
|
||||
required this.messageId,
|
||||
|
||||
@@ -1,6 +1,27 @@
|
||||
/// States for message-related operations in the MessageBloc.
|
||||
///
|
||||
/// This file defines all possible states that the MessageBloc can emit in response
|
||||
/// to message-related events. The states represent different phases of message
|
||||
/// operations including loading, success, and error states for real-time chat functionality.
|
||||
///
|
||||
/// State Categories:
|
||||
/// - **Initial State**: MessageInitial
|
||||
/// - **Loading States**: MessageLoading
|
||||
/// - **Success States**: MessagesLoaded
|
||||
/// - **Error States**: MessageError
|
||||
///
|
||||
/// The states support real-time chat features including message streaming,
|
||||
/// reactions, editing, and deletion within group conversations.
|
||||
///
|
||||
/// All states extend [MessageState] and implement [Equatable] for proper
|
||||
/// equality comparison and state change detection in the BLoC pattern.
|
||||
import 'package:equatable/equatable.dart';
|
||||
import '../../models/message.dart';
|
||||
|
||||
/// Base class for all message-related states.
|
||||
///
|
||||
/// All message states must extend this class and implement the [props] getter
|
||||
/// for proper equality comparison in the BLoC pattern.
|
||||
abstract class MessageState extends Equatable {
|
||||
const MessageState();
|
||||
|
||||
@@ -8,14 +29,41 @@ abstract class MessageState extends Equatable {
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
/// The initial state of the MessageBloc before any operations are performed.
|
||||
///
|
||||
/// This is the default state when the bloc is first created and represents
|
||||
/// a clean slate with no message data loaded or operations in progress.
|
||||
class MessageInitial extends MessageState {}
|
||||
|
||||
/// State indicating that a message operation is currently in progress.
|
||||
///
|
||||
/// This state is emitted when the bloc is performing operations like
|
||||
/// loading messages or initializing the real-time message stream.
|
||||
/// UI components can use this state to show loading indicators.
|
||||
class MessageLoading extends MessageState {}
|
||||
|
||||
/// State containing a list of successfully loaded messages for a group.
|
||||
///
|
||||
/// This state is emitted when messages have been successfully retrieved
|
||||
/// from the repository, either through initial loading or real-time updates.
|
||||
/// The state includes both the messages and the group ID for context.
|
||||
/// The UI can use this data to display the chat conversation.
|
||||
///
|
||||
/// Properties:
|
||||
/// [messages]: List of Message objects in the conversation
|
||||
/// [groupId]: The unique identifier of the group these messages belong to
|
||||
class MessagesLoaded extends MessageState {
|
||||
/// The list of messages in the conversation
|
||||
final List<Message> messages;
|
||||
|
||||
/// The unique identifier of the group
|
||||
final String groupId;
|
||||
|
||||
/// Creates a MessagesLoaded state.
|
||||
///
|
||||
/// Args:
|
||||
/// [messages]: The list of messages to include in this state
|
||||
/// [groupId]: The group ID these messages belong to
|
||||
const MessagesLoaded({
|
||||
required this.messages,
|
||||
required this.groupId,
|
||||
@@ -25,9 +73,23 @@ class MessagesLoaded extends MessageState {
|
||||
List<Object?> get props => [messages, groupId];
|
||||
}
|
||||
|
||||
/// State indicating that a message operation has failed.
|
||||
///
|
||||
/// This state is emitted when any message operation encounters an error,
|
||||
/// such as failing to load messages, send a message, or perform other
|
||||
/// message-related operations. It contains an error message that can be
|
||||
/// displayed to the user to explain what went wrong.
|
||||
///
|
||||
/// Properties:
|
||||
/// [message]: An error message describing what went wrong
|
||||
class MessageError extends MessageState {
|
||||
/// The error message to display to the user
|
||||
final String message;
|
||||
|
||||
/// Creates a MessageError state.
|
||||
///
|
||||
/// Args:
|
||||
/// [message]: The error message to display
|
||||
const MessageError(this.message);
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user