Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
history_collections_bloc.dart
Go to the documentation of this file.
1import 'package:equatable/equatable.dart';
2import 'package:flutter_bloc/flutter_bloc.dart';
3
4import '../../../../../core/common/entities/collection_entity.dart';
5import '../../../../../core/error/failures.dart';
6import '../../../../../core/services/service_locator.dart';
7import '../../../domain/usecases/get_history_collections_usecase.dart';
8
9part 'history_collections_event.dart';
10part 'history_collections_state.dart';
11
12class HistoryCollectionsBloc extends Bloc<HistoryCollectionsEvent, HistoryCollectionsState> {
13
15
16 HistoryCollectionsBloc(): super(HistoryCollectionsInitial()) {
17 on<LoadHistoryCollectionsEvent>(_onLoadHistoryCollections);
18 on<LoadHistoryCollectionsWithDateRangeEvent>(_onLoadHistoryCollectionsWithDateRange);
19 }
20
23 Emitter<HistoryCollectionsState> emit,
24 ) async {
25 emit(HistoryCollectionsLoading());
26 final result = await getHistoryCollectionsUsecase(
27 GetHistoryCollectionsParams(
28 userId: event.userId,
29 period: event.period,
30 ),
31 );
32 result.fold(
33 (failure) => emit(HistoryCollectionsError(failure: failure)),
35 );
36 }
37
39 LoadHistoryCollectionsWithDateRangeEvent event,
40 Emitter<HistoryCollectionsState> emit,
41 ) async {
42 emit(HistoryCollectionsLoading());
43 final result = await getHistoryCollectionsUsecase(
44 GetHistoryCollectionsParams(
45 userId: event.userId,
46 dateStart: event.dateStart,
47 dateEnd: event.dateEnd,
48 ),
49 );
50 result.fold(
51 (failure) => emit(HistoryCollectionsError(failure: failure)),
53 );
54 }
55}
sealed class AuthenticationState extends Equatable failure
sealed class CheckInOutEvent extends Equatable userId
Future< void > _onLoadHistoryCollectionsWithDateRange(LoadHistoryCollectionsWithDateRangeEvent event, Emitter< HistoryCollectionsState > emit,) async
Future< void > _onLoadHistoryCollections(LoadHistoryCollectionsEvent event, Emitter< HistoryCollectionsState > emit,) async
sealed class CollectionsState extends Equatable collections
GetHistoryCollectionsUsecase({required this.repository})
const LoadHistoryCollectionsEvent({ required this.userId, required this.period, })
const HistoryCollectionsLoaded({required this.collections})
abstract class PeriodEvent extends Equatable period
final sl