Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX - The filter applies it to the filtered list instead of to all items in the initial list. #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arakakil
Copy link

The filter applies it to the filtered list instead of to all items in the initial list.

The filter method of the FilterState class applies the filter on the items (_items) containing the items that were filtered as you type in the search field.

If a variable is added, e.g. List? _allItems; in which the original list is stored as follows:

FilterState({List<K>? allItems, List<K>? selectedItems}) {
    this.selectedItems = selectedItems;
    items = allItems;
    _allItems = allItems;
  }

And you modify the filter function to use the _allItems variable instead of _items, the problem is solved.

// perform filter operation
  void filter(bool Function(K) filter) {
    _items = _allItems!.where(filter).toList();
    notifyListeners();
  }

You might consider doing a merge of this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant