I am trying to build logic based on detecting user keyboard events (e.g., when a user presses the backspace in a textfield). This seems to work on my builds for Android devices, but is not working for iOS devices. It seems as if the KeyboardListener that is wrapping my textfield is not being called when the user presses a key.
I have tried both the KeyboardListener and the RawKeyboardListener, and neither seem to work. How can I get this to work on iOS the same as it works for Android?
Here is a snippet of my code:
import 'package:flutter/material.dart'
class TestComponent extends StatelessWidget {
const TestComponent({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
child: KeyboardListener(
onKeyEvent: (key) {
print(key);
},
focusNode: FocusNode(),
child: TextField()),
);
}
}