Is there any way to catch a keypress in textfield? In my case, when the user press enter key inside the text field, the values will be stored. For this to happen, I need to use Keypress-event like in Kotlin+Android. I just started trying flutter this week since it is interesting and cross-platform.
RawKeyboardListener(
child: TextFormField(
keyboardType: TextInputType.text,
decoration: new InputDecoration(labelText: "Phone"),
validator: (val) => val.length == 0 ? 'Enter your phone' : null,
onSaved: (val) => this.phone = val,
),
focusNode: FocusNode(),
onKey: (RawKeyEvent event) {
print(event.data.logicalKey.keyId);
if (event.runtimeType == RawKeyDownEvent ) {
print("asdadda");
}
},
),
But I don't know why it doesn't work however I press key.