👋

【Flutter】TextInput onChange with editting controller listener

2024/04/04に公開
Widget build(BuildContext context) {
    final controller = useTextEditingController();

    void onControllerChange() {
      print('OnControllerChange - ${controller.value.text}');
    }

    useEffect(() {
      controller.addListener(onControllerChange);

      return () => controller.removeListener(onControllerChange);
    }, [controller]);

    return TextFormField(
      controller: controller,
    );
  }

https://pub.dev/documentation/flutter_hooks/0.21.0/flutter_hooks/useTextEditingController-constant.html
https://github.com/rrousselGit/flutter_hooks/issues/261

Discussion