how can I clear value in get x controller? for now I need to restart my app every time I need to input different value.
my text controller class :
import 'package:get/get.dart';
class TextControllers extends GetxController {
Rx<TextEditingController> usernameController = TextEditingController().obs;
Rx<TextEditingController> passwordController = TextEditingController().obs;
Rx<TextEditingController> vendor1Controller = TextEditingController().obs;
Rx<TextEditingController> stocktableController = TextEditingController().obs;
Rx<TextEditingController> fixassetController = TextEditingController().obs;
}
CodePudding user response:
just use clear function
clearTextInput(){
usernameController.clear();
passwordController.clear();
vendor1Controller.clear();
stocktableController.clear();
fixassetController.clear();
}
CodePudding user response:
You can try this for clearing TextEditingController value.
Paste this inside you TextControllers
class.
@override
void onInit() {
super.onInit();
usernameController.value.clear();
passwordController.value.clear();
vendor1Controller.value.clear();
stocktableController.value.clear();
fixassetController.value.clear();
}