1import 'package:bloc/bloc.dart';
2import 'package:equatable/equatable.dart';
3import 'package:google_maps_flutter/google_maps_flutter.dart';
5import '../../../../../core/error/failures.dart';
6import '../../../../../core/services/service_locator.dart';
7import '../../../domain/entities/req/req_create_routing_entity.dart';
8import '../../../domain/entities/res/res_create_routing_entity.dart';
9import '../../../domain/entities/res/res_weekly_collection_entity.dart';
10import '../../../domain/entities/res/res_collection_to_schedule_entity.dart';
11import '../../../domain/usecases/create_routing_usecase.dart';
13part
'routing_planning_event.dart';
14part
'routing_planning_state.dart';
17 extends Bloc<RoutingPlanningEvent, RoutingPlanningState> {
31 Emitter<RoutingPlanningState> emit,
33 final currentState = state;
35 emit(currentState.copyWith(
48 SetSelectedCollectionsEvent event,
49 Emitter<RoutingPlanningState> emit,
51 final currentState = state;
61 Emitter<RoutingPlanningState> emit,
63 final currentState = state;
73 Emitter<RoutingPlanningState> emit,
75 final currentState = state;
77 emit(currentState.copyWith(
90 CreateRoutingEvent event,
91 Emitter<RoutingPlanningState> emit,
93 final currentState = state;
126 failure:
const ValidationFailure(
127 message:
'Missing required data for routing creation'),
138 emit(RoutingPlanningLoading());
150 duration: event.duration,
153 endLocationLatitude:
endLocation!.latitude.toString(),
154 endLocationLongitude:
endLocation.longitude.toString(),
155 purchaseOrders: purchaseOrders,
171 (routing) => emit(RoutingPlanningSuccess(routing: routing)),
176 ResetRoutingPlanningEvent event,
177 Emitter<RoutingPlanningState> emit,
179 emit(RoutingPlanningInitial());
sealed class AuthenticationState extends Equatable failure
void _onResetRoutingPlanning(ResetRoutingPlanningEvent event, Emitter< RoutingPlanningState > emit,)
void _onSetCollectionsToSchedule(SetCollectionsToScheduleEvent event, Emitter< RoutingPlanningState > emit,)
Future< void > _onCreateRouting(CreateRoutingEvent event, Emitter< RoutingPlanningState > emit,) async
void _onSetEndLocation(SetEndLocationEvent event, Emitter< RoutingPlanningState > emit,)
final CreateRoutingUseCase createRoutingUseCase
void _onSetStartLocation(SetStartLocationEvent event, Emitter< RoutingPlanningState > emit,)
void _onSetSelectedCollections(SetSelectedCollectionsEvent event, Emitter< RoutingPlanningState > emit,)
abstract class CollectionsToScheduleEvent extends Equatable request
DriverEntity({required this.id})
const SetCollectionsToScheduleEvent({required this.collections})
const SetStartLocationEvent({ required this.location, required this.address, })
const SetEndLocationEvent({ required this.location, required this.address, })
const RoutingPlanningLoaded({ this.startLocation, this.startAddress, this.selectedCollections, this.collectionsToSchedule, this.endLocation, this.endAddress, })
final String startAddress
const RoutingPlanningError({ required this.failure, this.startLocation, this.startAddress, this.selectedCollections, this.collectionsToSchedule, this.endLocation, this.endAddress, })
sealed class RoutingPlanningState extends Equatable startLocation
final Set< ResWeeklyCollectionEntity > selectedCollections
final List< ResCollectionToScheduleEntity > collectionsToSchedule
class SearchWeeklyCollectionsEvent extends WeeklyCollectionsEvent collection