Files
Tanami_App/lib/features/otpVerification/bloc/otp_bloc.dart
2024-07-18 18:51:01 +05:30

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"));
}
}
}