selfprivacy.org.app/lib/logic/cubit/jobs/jobs_state.dart

29 lines
630 B
Dart
Raw Normal View History

2021-05-25 21:53:54 +00:00
part of 'jobs_cubit.dart';
2021-07-29 05:24:42 +00:00
abstract class JobsState extends Equatable {
@override
List<Object?> get props => [];
}
2021-05-25 21:53:54 +00:00
2021-07-29 05:24:42 +00:00
class JobsStateLoading extends JobsState {}
2021-05-25 21:53:54 +00:00
2021-07-29 05:24:42 +00:00
class JobsStateEmpty extends JobsState {}
2021-05-25 21:53:54 +00:00
2021-07-29 05:24:42 +00:00
class JobsStateWithJobs extends JobsState {
JobsStateWithJobs(this.jobList);
final List<Job> jobList;
2021-05-25 21:53:54 +00:00
2022-06-05 19:36:32 +00:00
JobsState removeById(final String id) {
final List<Job> newJobsList =
jobList.where((final element) => element.id != id).toList();
2021-07-29 05:24:42 +00:00
if (newJobsList.isEmpty) {
return JobsStateEmpty();
}
return JobsStateWithJobs(newJobsList);
2021-05-25 21:53:54 +00:00
}
@override
2021-07-29 05:24:42 +00:00
List<Object?> get props => jobList;
2021-05-25 21:53:54 +00:00
}