Skip to content

Commit

Permalink
Set initial scroll offset to zero if the selected item doesn't exist …
Browse files Browse the repository at this point in the history
…in search result
  • Loading branch information
AhmedLSayed9 committed Jun 1, 2024
1 parent a6695b6 commit 8f68a80
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/dropdown_button2/lib/src/dropdown_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> {
itemHeights.length,
);
if (searchData?.searchController?.text case final searchText?) {
offset += _getSearchItemsHeight(index, searchText);
final searchMatchFn =
searchData?.searchMatchFn ?? _defaultSearchMatchFn();
final selectedItemExist = searchMatchFn(items[index], searchText);
if (selectedItemExist) {
offset += _getSearchItemsHeight(index, searchText);
}
} else {
for (int i = 0; i < index; i++) {
offset += itemHeights[i];
Expand Down

0 comments on commit 8f68a80

Please sign in to comment.