fix : dio call
This commit is contained in:
38
packages/auth/lib/presentation/widget/captcha/logic.dart
Normal file
38
packages/auth/lib/presentation/widget/captcha/logic.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/di/auth_di.dart';
|
||||
import 'package:rasadyar_auth/data/models/response/captcha/captcha_response_model.dart';
|
||||
import 'package:rasadyar_auth/data/repositories/auth_repository_imp.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class CaptchaWidgetLogic extends GetxController
|
||||
with StateMixin<CaptchaResponseModel> {
|
||||
TextEditingController textController = TextEditingController();
|
||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
AuthRepositoryImpl authRepository = diAuth.get<AuthRepositoryImpl>();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
getCaptcha();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Future<void> getCaptcha() async {
|
||||
change(null, status: RxStatus.loading());
|
||||
safeCall(
|
||||
call: () async => await authRepository.captcha(),
|
||||
onSuccess: (value) {
|
||||
change(value, status: RxStatus.success());
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
change(null, status: RxStatus.error(error.toString()));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user