We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.input text 2.close the softkeyboard,the text will be cleared
Every time the build call,the _oldPWControll print as a new instance
class Demo extends HookWidget { final _oldPWControll = TextEditingController(); final _oldPWFN = FocusNode(); @override Widget build(BuildContext context) { print(_oldPWControll); return Scaffold( resizeToAvoidBottomInset: true, body: TextField( controller: _oldPWControll, textInputAction: TextInputAction.next, focusNode: _oldPWFN, decoration: InputDecoration( hintText: "请输入", contentPadding: EdgeInsets.fromLTRB(35.0, 12.0, 12.0, 12.0), ), ), ); } }
When Demo as the home Widget of MaterialApp,it is work but push to the Demo,problems will arise
The text was updated successfully, but these errors were encountered:
You should not create these as fields of the class.
Instead create them using hooks inside the build method
Widget build(BuildContext context) { final controller = useMemoized(() => TextEditingController()); ... }
Sorry, something went wrong.
you mean I can't define any final variables directly from KookWidget?
Nor can you do so with any other kind of widgets.
Widgets are immutable. You need a State subclass using hooks to preserve values between builds.
State
No branches or pull requests
1.input text
2.close the softkeyboard,the text will be cleared
Every time the build call,the _oldPWControll print as a new instance
When Demo as the home Widget of MaterialApp,it is work
but push to the Demo,problems will arise
The text was updated successfully, but these errors were encountered: