feat : new auth in chicken
This commit is contained in:
34
packages/chicken/lib/presentation/widget/captcha/logic.dart
Normal file
34
packages/chicken/lib/presentation/widget/captcha/logic.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class CaptchaWidgetLogic extends GetxController with StateMixin<String> {
|
||||
TextEditingController textController = TextEditingController();
|
||||
RxnString captchaKey = RxnString();
|
||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
|
||||
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: 500));
|
||||
captchaKey.value = (random.nextInt(900_000) + 100_000).toString();
|
||||
change(captchaKey.value, status: RxStatus.success());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user