In Android, we can call setOnFocusChangeListener()
, do something in onFocusChanged()
method, but flutter does not provider onFocus()
interface like onTap()
in GestureDetector or onKey()
in RawKeyboardListener.
I have read flutter api about focus, https://docs.flutter.io/flutter/widgets/FocusManager-class.html but I can't find a way to realize my request, anyone who can give me a hand?
autofocus property Null safety bool autofocus. Whether this text field should focus itself if nothing else is already focused. If true, the keyboard will open as soon as this text field obtains focus. Otherwise, the keyboard is only shown after the user taps the text field.
In addtion you can use Focus widget.
Focus( child: TextFormField(...), onFocusChange: (hasFocus) { if(hasFocus) { // do stuff } }, )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With