useTextController function
Implementation
UseTextController useTextController({
String initialValue = "",
int throttle = 0,
}) {
final text = useState<String>(initialValue);
final throttleFunction = useMemoized(() => DelayThrottle(throttle), []);
final controller = useMemoized(() {
final controller = TextEditingController();
controller.text = initialValue;
controller.addListener(() {
if (throttle > 0) {
throttleFunction <<
() {
text.value = controller.text;
};
} else {
text.value = controller.text;
}
});
return controller;
}, []);
return UseTextController(controller: controller, text: text.value);
}