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

Typeahead should allow users to provide their own matching function #22

Open
wz2b opened this issue Aug 4, 2016 · 1 comment
Open
Assignees

Comments

@wz2b
Copy link

wz2b commented Aug 4, 2016

It would be a nice feature addition to let typeahead users specify their own matching filter (where they provide you with a function). This would facilitate:

  • Searching on more than one property of the object (e.g. object has a 'name' and a 'description')
  • Other custom matching, such as case-insensitivity or "startsWith"
@wz2b
Copy link
Author

wz2b commented Aug 4, 2016

I can KIND of work around this by using the asynchronous loader interface and do the filtering there:

  Future<List<String>>  fetchData(String query) async {
    String search = query.toLowerCase();
    List<Tag> allTags = await tagCache.getAll();

    return allTags.where( (Tag item) =>
        item.name?.toLowerCase()?.contains(search) ||
            item.description?.toLowerCase()?.contains(search)
    ).map((Tag t) => t.name);
  }

this combines the concept of a user-configurable item filter with the asynchronous loading, and the pattern works even if you don't need asynchronous loading at all (you just pretend you do but return the filtered list).

So maybe the developers will decide this isn't that adding the ability to specify a filter is not that important.

@luisvt luisvt self-assigned this Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants