BIG FAT
This commit is contained in:
@ -4,28 +4,19 @@ import 'package:hl_lieferservice/widget/operations/bloc/operation_state.dart';
|
||||
|
||||
class OperationBloc extends Bloc<OperationEvent, OperationState> {
|
||||
OperationBloc() : super(OperationIdle()) {
|
||||
on<LoadOperation>(_loadOperation);
|
||||
on<FailOperation>(_failOperation);
|
||||
on<FinishOperation>(_finishOperation);
|
||||
}
|
||||
|
||||
Future<void> _loadOperation(LoadOperation event, Emitter<OperationState> emit) async {
|
||||
emit(OperationLoading());
|
||||
}
|
||||
|
||||
Future<void> _failOperation(FailOperation event, Emitter<OperationState> emit) async {
|
||||
emit(OperationFailed(message: event.message));
|
||||
|
||||
await Future.delayed(Duration(seconds: 5));
|
||||
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
emit(OperationIdle());
|
||||
}
|
||||
|
||||
Future<void> _finishOperation(FinishOperation event, Emitter<OperationState> emit) async {
|
||||
emit(OperationFinished(message: event.message));
|
||||
|
||||
await Future.delayed(Duration(seconds: 5));
|
||||
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
emit(OperationIdle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
abstract class OperationEvent {}
|
||||
|
||||
class LoadOperation extends OperationEvent {}
|
||||
|
||||
class FailOperation extends OperationEvent {
|
||||
String message;
|
||||
|
||||
@ -12,4 +10,4 @@ class FinishOperation extends OperationEvent {
|
||||
String? message;
|
||||
|
||||
FinishOperation({this.message});
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,6 @@ abstract class OperationState {}
|
||||
|
||||
class OperationIdle extends OperationState {}
|
||||
|
||||
class OperationLoading extends OperationState {}
|
||||
|
||||
class OperationFailed extends OperationState {
|
||||
String message;
|
||||
|
||||
@ -14,4 +12,4 @@ class OperationFinished extends OperationState {
|
||||
String? message;
|
||||
|
||||
OperationFinished({this.message});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user