rrousselGit / flutter_hooks

React hooks for Flutter. Hooks are a new kind of object that manages a Widget life-cycles. They are used to increase code sharing between widgets and as a complete replacement for StatefulWidget.
MIT License
3.07k stars 175 forks source link

Documentation of useTextEditingController with useEffect needs to be updated #325

Open AhmedLSayed9 opened 1 year ago

AhmedLSayed9 commented 1 year ago

Hello,

The doc of useTextEditingController suggests using useEffect to update the TextEditingController.text whenever a provided ValueListenable changes.

But, When the provided ValueListenable updates the TextEditingController.text for the second time it'll throw an exception: setState() or markNeedsBuild() called during build

Suggestion: Delaying the update by a frame using Future.microtask inside useEffect fixes the issue.