Open ghost opened 2 years ago
me too
@SaharatPr @HASHCAPDOTCOM @crawlinknetworks @namdegnah anyone found solution ? please let us know
@Adeel-Sultan @SaharatPr @HASHCAPDOTCOM Yea, I found a solution, but you'll have to change some lines in the package files as the focus widget, onKey is going to be deprecated soon, so use onKeyEvent and change some lines of a code in the package itself.
in the dropdown.dart (implementation file of DropdownFormField widget) file of the package, replace _onKeyPressed function with this code
_onKeyPressed(KeyEvent event) {
//print('_onKeyPressed : ${event.character}');
if (event.logicalKey==LogicalKeyboardKey.enter) {
if (_searchFocusNode.hasFocus) {
_toggleOverlay();
} else {
_toggleOverlay();
}
//return false;
return KeyEventResult.ignored;
} else if (event.logicalKey==LogicalKeyboardKey.escape) {
_removeOverlay();
return KeyEventResult.handled;
//return true;
} else if (event.logicalKey==LogicalKeyboardKey.arrowDown) {
int v = _listItemFocusedPosition;
v++;
if (v >= _options!.length) v = 0;
_listItemFocusedPosition = v;
_listItemsValueNotifier.value = List<T>.from(_options ?? []);
//return true;
return KeyEventResult.handled;
} else if (event.logicalKey==LogicalKeyboardKey.arrowUp) {
int v = _listItemFocusedPosition;
v--;
if (v < 0) v = _options!.length - 1;
_listItemFocusedPosition = v;
_listItemsValueNotifier.value = List<T>.from(_options ?? []);
//return true;
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
//return false;
}
And RawKeyEvent is now will be replaced by KeyEvent and don't forget to restart/reinstall the application after saving these changes, for these to take effect.
@Adeel-Sultan @SaharatPr @HASHCAPDOTCOM Yea, I found a solution, but you'll have to change some lines in the package files as the focus widget, onKey is going to be deprecated soon, so use onKeyEvent and change some lines of a code in the package itself.
in the dropdown.dart (implementation file of DropdownFormField widget) file of the package, replace _onKeyPressed function with this code
_onKeyPressed(KeyEvent event) { //print('_onKeyPressed : ${event.character}'); if (event.logicalKey==LogicalKeyboardKey.enter) { if (_searchFocusNode.hasFocus) { _toggleOverlay(); } else { _toggleOverlay(); } //return false; return KeyEventResult.ignored; } else if (event.logicalKey==LogicalKeyboardKey.escape) { _removeOverlay(); return KeyEventResult.handled; //return true; } else if (event.logicalKey==LogicalKeyboardKey.arrowDown) { int v = _listItemFocusedPosition; v++; if (v >= _options!.length) v = 0; _listItemFocusedPosition = v; _listItemsValueNotifier.value = List<T>.from(_options ?? []); //return true; return KeyEventResult.handled; } else if (event.logicalKey==LogicalKeyboardKey.arrowUp) { int v = _listItemFocusedPosition; v--; if (v < 0) v = _options!.length - 1; _listItemFocusedPosition = v; _listItemsValueNotifier.value = List<T>.from(_options ?? []); //return true; return KeyEventResult.handled; } return KeyEventResult.ignored; //return false; }
And RawKeyEvent is now will be replaced by KeyEvent and don't forget to restart/reinstall the application after saving these changes, for these to take effect.
@HASHCAPDOTCOM could you please change this in file and check if work, updates all files and update library too?
@HASHCAPDOTCOM could you please change this in file and check if work, updates all files and update library too?
Yes, I have verified, it is working now and I have also created a pull request with all the changes.
@Adeel-Sultan @SaharatPr @namdegnah I just created my own package for Dropdown Text Search with keyboard support, feel free to check it out. Thank you
dropdown_text_search: ^0.0.1
same issue
Hi,
When using the example and then type in the search DropdownFormField this error message is produced. Each keystroke produces this error.
Using Chrome as the browser.
Paul Brassington
════════ Exception caught by services library ══════════════════════════════════ The following TypeErrorImpl was thrown while processing the key message handler: Expected a value of type 'KeyEventResult', but got one of type 'bool'