import 'dart:math'; import 'package:flutter/material.dart'; import 'package:rasadyar_core/core.dart'; class CaptchaWidgetLogic extends GetxController with StateMixin { TextEditingController textController = TextEditingController(); RxnString captchaKey = RxnString(); GlobalKey formKey = GlobalKey(); final Random random = Random(); @override void onInit() { super.onInit(); getCaptcha(); } @override void onClose() { textController.clear(); textController.dispose(); super.onClose(); } Future 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()); } }