search_delegate_flutter

Last updated:

0 purchases

search_delegate_flutter Image
search_delegate_flutter Images
Add to Cart

Description:

search delegate flutter

search_delegate_flutter #
Search delegate lets you handle your list of items in a way that you can search through them efficiently and get the
items that meets your conditions.
Getting Started #
Note that all delegates extends ChangeNotifier.
Simple usage example:
import the package
import 'package:search_delegate_flutter/search_delegate_flutter.dart';
copied to clipboard
create the items like so. delegates at the start does not have root nodes, so the first addition to them will be their root node.
List<int> items = List.generate(1000,(index) => index);
TreeSearchDelegate<int> treeDelegate = TreeSearchDelegate(items);
ChainedSearchDelegate<int> chainedDelegate = ChainedSearchDelegate(items)
copied to clipboard
Simple Usage #
for TreeSearchDelegate, add method adds a node under the root if parentNodeLabel is not specified.
notice that add method has a generic type, which is used to determine params type. initialValue means the starting value of the node and when searching through it will be used.You can also change it later,mind that doing so will effect future searches.
You can add nodes to above examples like so:

treeDelegate.add<int>((item, param) => item > param, 150,
nodeLabel: 'root');

treeDelegate.add<int>((item, param) => item < param, 1500,
nodeLabel: 'lesserThan1500', filterType: TREE_FILTER_TYPE.ONLY);
treeDelegate.add<int>((item,param) => item % param == 0,3,nodeLabel:'dividableBy3',parentNodeLabel:'lesserThan1500')

copied to clipboard
for ChainedSearchDelegate it is simpler
chainedDelegate.chain<int>((item,param) => item < param,140);
copied to clipboard
You can do all type of searches.This libraries main goal is to help manage and maintain searching practices.
For example a Regular expression search would something like this:
//for chained delegate
var regex = RegExp(".*a.*");
chainedDelegate.chain<RegExp>(
(item, param) => param.hasMatch(item.name), regex);
treeDelegate.add<RegExp>((item,param) => param.hasMatch(item.name),regex,nodeLabel:'matchNameRegexp')
copied to clipboard
While using treeSearchDelegate, you can create the root and the first subNodes by calling treeDelegate.createNodeTree.
If insertIntoTree is false and the root is not null then the created root node will be returned with the subNodes.
An example:
treeSearchDelegate.createNodeTree(
[
TreeNodeData(
initialValue: 450, search: (item, param) => item.id < param),
TreeNodeData(
initialValue: 2500, search: (item, param) => item.price > param),
TreeNodeData(
search: (item, param) => item.duration < param,
initialValue: 2,
),
TreeNodeData(
search: (item, param) => item.id > param,
initialValue: 850,
),
TreeNodeData(
search: (item, param) => item.price < param, initialValue: 250),
],
(item, param) => item.isOpen == param,
true,
insertIntoTree: true,
filterType: TREE_FILTER_TYPE.ONLY,
);

copied to clipboard

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.