39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
import 'dart:math';
|
|
|
|
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();
|
|
RxnString captchaKey = RxnString();
|
|
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
|
AuthRepositoryImpl authRepository = diAuth.get<AuthRepositoryImpl>();
|
|
final Random random = Random();
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
|
|
getCaptcha();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
textController.clear();
|
|
textController.dispose();
|
|
super.onClose();
|
|
}
|
|
|
|
Future<void> getCaptcha() async {
|
|
change(null, status: RxStatus.loading());
|
|
textController.clear();
|
|
await Future.delayed(Duration(milliseconds: 800));
|
|
captchaKey.value = (random.nextInt(900000)+100000).toString();
|
|
change(value, status: RxStatus.success());
|
|
|
|
}
|
|
}
|