languagetool_textfield
languagetool_textfield copied to clipboard
onTextChange call
It appears that onTextChange call does not take in account corrected spelling. If I use the controller, everything works as expected. However, this makes my code more complex and difficult to maintain.
Yes I confirm that when we apply a correction through the pop-up the callback is not called and there's no other events that could notify us. Did you find a workaround @zthrive?
While this issue is being fixed, here's how I'm handling the focus behavior in my implementation... Not perfect but it does the trick for my usage (since i don't need the updated values until i'm clicking out of the textfields)
// Initialize focus nodes
late final FocusNode _commentsFocusNode;
late final FocusNode _conductFocusNode;
@override
void initState() {
super.initState();
_commentsFocusNode = FocusNode();
_commentsFocusNode.addListener(() {
if (!_commentsFocusNode.hasFocus) {
widget.onCommentsChanged?.call(_commentsController.text);
}
});
_conductFocusNode = FocusNode();
_conductFocusNode.addListener(() {
if (!_conductFocusNode.hasFocus) {
widget.onConductChanged?.call(_conductController.text);
}
});
}
@override
void dispose() {
_commentsFocusNode.dispose();
_conductFocusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AppCard(
child: Column(
children: [
// ... other widgets ...
AppLangTextField(
controller: _commentsController,
focusNode: _commentsFocusNode,
// ... other properties ...
),
// ... other widgets ...
AppLangTextField(
controller: _conductController,
focusNode: _conductFocusNode,
// ... other properties ...
),
// ... other widgets ...
],
),
);
}