You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
41 lines
1.3 KiB
import 'dart:async';
|
|
import 'package:bloc/bloc.dart';
|
|
import 'package:hadi_hoda_flutter/core/status/base_status.dart';
|
|
import 'package:hadi_hoda_flutter/features/intro/domain/entity/intro_entity.dart';
|
|
import 'package:hadi_hoda_flutter/features/intro/domain/usecases/get_intro_usecase.dart';
|
|
import 'package:hadi_hoda_flutter/features/intro/presentation/bloc/intro_event.dart';
|
|
import 'package:hadi_hoda_flutter/features/intro/presentation/bloc/intro_state.dart';
|
|
|
|
class IntroBloc extends Bloc<IntroEvent, IntroState> {
|
|
/// ------------constructor------------
|
|
IntroBloc(
|
|
this._getIntroUseCase,
|
|
) : super(const IntroState()) {
|
|
on<GetIntroEvent>(_getIntroEvent);
|
|
}
|
|
|
|
/// ------------UseCases------------
|
|
final GetIntroUseCase _getIntroUseCase;
|
|
|
|
/// ------------Variables------------
|
|
|
|
/// ------------Controllers------------
|
|
|
|
/// ------------Functions------------
|
|
|
|
/// ------------Api Calls------------
|
|
FutureOr<void> _getIntroEvent(event, emit) async {
|
|
await _getIntroUseCase(event.introParams).then(
|
|
(value) {
|
|
value.fold(
|
|
(data) {
|
|
emit(state.copyWith(getIntroStatus: BaseComplete<IntroEntity>(data)));
|
|
},
|
|
(error) {
|
|
emit(state.copyWith(getIntroStatus: BaseError(error.errorMessage)));
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|