gumbarros / DevWidgets

DevWidgets is a Flutter application with several tools such as generators, formatters and converters for developers. It's directly inspired by DevToys.
https://gumbarros.github.io/DevWidgets
MIT License
153 stars 13 forks source link

Implement custom function for the search box #7

Open gumbarros opened 1 year ago

gumbarros commented 1 year ago

Currently the searchbox only filter tools by menu name. The best way to search would be adding search tags plus the tool name in the menu and home page.

kphanipavan commented 1 year ago

Here's a search I deviced:

let x be the search term, The results have to be list in the order below:

  1. name starts with x
  2. name contains x
  3. tag starts with x
  4. tag contains x
  5. description starts with x
  6. desc contains x

For this, we can add static data members to the stateless page widgets and use it as key for searching.

Also, as the list increases, we can asynchronously add matched to the search results. Ex: Loop over 1 and 2, show matches, loop over 3,4 and append is search box is still open, and so on.

Also, you mentioned tags, plural. Are multiple necessary? help me understand with a example plis.

gumbarros commented 1 year ago

Great algorithm! I was thinking in add the search tags on the Tool class as a List like the original DevToys and then add to the DTO object LinuxMenuItem. Example for JSON Formatter(I'm on the phone and maybe the syntax is incorrect):

@override
List<String> get searchTags => ["Formatter","JSON","Sort"]
kphanipavan commented 1 year ago

https://github.com/fzyzcjy/flutter_smooth

Ensures smooth listview animations regardless of the size.

Found it on reddit, might be useful when search is being implemented.