29 lines
816 B
Dart
29 lines
816 B
Dart
import 'package:bloc/bloc.dart';
|
|
|
|
import '../../../Api_Helper/base_manager.dart';
|
|
import '../domain/Repository/otp_api.dart';
|
|
import 'otp_event.dart';
|
|
import 'otp_state.dart';
|
|
|
|
class OTPBloc extends Bloc<OTPEvent, OTPState> {
|
|
OTPBloc() : super(OTPInitial()) {
|
|
on<RequestOTP>(requestOTPCall);
|
|
// on<VerifyOTP>(VerifyOTPCall);
|
|
}
|
|
Future<void> requestOTPCall(RequestOTP event, Emitter<OTPState> emit) async {
|
|
emit(OTPLoading());
|
|
final otprequestdata = event.OTPRequestData;
|
|
|
|
try {
|
|
ResponseData response = await OTPAPI().requestOTP(otprequestdata);
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
emit(OTPLoaded());
|
|
} else {
|
|
emit(OTPFailed("Oops something went wrong"));
|
|
}
|
|
} catch (e) {
|
|
emit(OTPError("Oops something went wrong"));
|
|
}
|
|
}
|
|
}
|