You can use onEditingComplete property of TextField. You can check the document here
TextField(
onEditingComplete: (String keyword) {
//do your logic
},
)
Edit 1: My mistake. I think you want something like focus listener.
1- Add Listener to FocusNode:
@override
void initState() {
super.initState();
_focusNode.addListener(_onFocusChange);
}
@override
void dispose() {
super.dispose();
_focusNode.removeListener(_onFocusChange);
}
2- Do your logic in _onFocusChange method.
void _onFocusChange() {
if (_focusNode.hasFocus) {
//If focusNode hasFocus.
} else {
//If focusNode doesn't have focus.
}
}
That's why, if user exits the keyboard without pressing done. The Focus Node handles this situation.