handleKeyEvent method
Handles user key inputs to update the internal value.
Implementation
@override
void handleKeyEvent(KeyEvent event) {
if (options.isEmpty) return;
if (event.type == KeyType.up) {
_selectedIndex = (_selectedIndex - 1).clamp(0, options.length - 1);
value = options[_selectedIndex].value;
if (_state != null) {
_state!.setState(() {});
}
} else if (event.type == KeyType.down) {
_selectedIndex = (_selectedIndex + 1).clamp(0, options.length - 1);
value = options[_selectedIndex].value;
if (_state != null) {
_state!.setState(() {});
}
}
}