w
This commit is contained in:
31
lib/features/tasks/blocs/task_list_state.dart
Normal file
31
lib/features/tasks/blocs/task_list_state.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
part of 'task_list_cubit.dart';
|
||||
|
||||
enum TaskListStatus { initial, loading, success, failure }
|
||||
|
||||
class TaskListState extends Equatable {
|
||||
final TaskListStatus status;
|
||||
final List<TaskModel> tasks;
|
||||
final String? errorMessage;
|
||||
|
||||
const TaskListState({
|
||||
this.status = TaskListStatus.initial,
|
||||
this.tasks = const [],
|
||||
this.errorMessage,
|
||||
});
|
||||
|
||||
TaskListState copyWith({
|
||||
TaskListStatus? status,
|
||||
List<TaskModel>? tasks,
|
||||
String? errorMessage,
|
||||
}) {
|
||||
return TaskListState(
|
||||
status: status ?? this.status,
|
||||
tasks: tasks ?? this.tasks,
|
||||
// Se lo status è success o loading, puliamo eventuali errori precedenti
|
||||
errorMessage: errorMessage ?? this.errorMessage,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [status, tasks, errorMessage];
|
||||
}
|
||||
Reference in New Issue
Block a user