Skip to content

Instantly share code, notes, and snippets.

@raveesh-me
Created January 17, 2020 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raveesh-me/c06cdd9404c1241f50b1dd51c7c83680 to your computer and use it in GitHub Desktop.
Save raveesh-me/c06cdd9404c1241f50b1dd51c7c83680 to your computer and use it in GitHub Desktop.
dart MultiFilters
void main() {
var anda = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var divisibleByTwo = (int i) {
return i % 2 == 0;
};
var greaterThanThree = (int i) {
return i > 3;
};
var aloo = multiFilters<int>(anda, [
// divisibleByTwo,
// greaterThanThree,
]);
print(aloo);
}
typedef bool FilterFunction<T>(T t);
List<T> multiFilters<T>(
List<T> initialData, List<FilterFunction<T>> filterFunctions) {
var _initData = initialData;
filterFunctions.forEach((function) {
_initData = _initData.where(function).toList();
});
return _initData;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment