1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-09 06:18:49 +00:00

Add type param filter (#596)

Format code
Add match by type tests
This commit is contained in:
Sashika Nawarathne
2020-11-17 23:50:00 +05:30
committed by GitHub
parent 1091fb1f33
commit a0d314bf5e
4 changed files with 23 additions and 4 deletions

View File

@@ -9,6 +9,17 @@ bool matchesQuery(String query, String sampleAttributes) {
var queryWords = query.split(' ')..removeWhere((s) => s.isEmpty);
var attributes = sampleAttributes.split(' ')..removeWhere((s) => s.isEmpty);
// Test for type filter
// This will check whether a type parameter is present in the
// search query, and return false if the self type mismatches
// the query type
for (var word in queryWords) {
if ((word.contains('type:') && !attributes.contains(word)) ||
(word.contains('platform:') && !attributes.contains('type:demo'))) {
return false;
}
}
// Test for exact matches
if (attributes.contains(query)) {
return true;