2024-05-02 16:56:33 +05:30
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
|
|
|
|
import '../../Utils/base_manager.dart';
|
|
|
|
|
import '../../resources/routes/route_name.dart';
|
|
|
|
|
import '../Login/send_otp_api.dart';
|
|
|
|
|
import 'sendOtpObserver.dart';
|
|
|
|
|
|
|
|
|
|
class SendOtpBloc extends Bloc<SendOtpEvent, SendOtpState> {
|
|
|
|
|
SendOtpBloc() : super(SendOtpState.initial) {
|
|
|
|
|
on<SendOtp>(mapEventToState);
|
|
|
|
|
}
|
|
|
|
|
Future<void> mapEventToState(
|
|
|
|
|
SendOtp event, Emitter<SendOtpState> emit) async {
|
|
|
|
|
if (event is SendOtp) {
|
|
|
|
|
emit(SendOtpState.loading);
|
|
|
|
|
try {
|
|
|
|
|
final loginData = event.loginData;
|
|
|
|
|
var resp = await SendOtpAPI(loginData).sendOtpApi();
|
|
|
|
|
|
|
|
|
|
if (resp.status == ResponseStatus.SUCCESS) {
|
|
|
|
|
emit(SendOtpState.success);
|
2024-06-11 11:29:45 +05:30
|
|
|
}
|
|
|
|
|
else {
|
2024-05-02 16:56:33 +05:30
|
|
|
emit(SendOtpState.failure);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
emit(SendOtpState.failure);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|