match_sorter

Last updated:

0 purchases

match_sorter Image
match_sorter Images
Add to Cart

Description:

match sorter

match-sorter #
A dart adaptation of the match-sorter package for javascript
Examples #
Basic Usage #
import 'package:match_sorter/match_sorter.dart';

void main() {
List<Item> items = stringsToItems(['Chakotay', 'Brunt', 'Charzard']);
var searchQuery = 'Ch';

List<Item> matchedItems = matchSorter(
searchQuery: searchQuery,
items: items,
);

print(matchedItems);
// [{ value: Chakotay }, { value: Charzard }]
}
copied to clipboard
Multiple keys #
import 'package:match_sorter/match_sorter.dart';

void main() {
var items = [
{'name': 'baz', 'reverse': 'zab'},
{'name': 'bat', 'reverse': 'tab'},
{'name': 'foo', 'reverse': 'oof'},
{'name': 'bag', 'reverse': 'gab'},
];
var searchQuery = 'ab';
var keys = [Key('name'), Key('reverse')];


List<Item> matchedItems = matchSorter(
searchQuery: searchQuery,
items: items,
keys: keys
);

print(matchedItems);
// [ {'name': 'bag', 'reverse': 'gab'}, {'name': 'bat', 'reverse': 'tab'}, {'name': 'baz', 'reverse': 'zab'} ]
}
copied to clipboard


More examples coming soon. In the meantime you can browser the test suite to explore advanced usecases

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.