only show resutls if query is not empty
This commit is contained in:
parent
f7d4ded925
commit
ba2eb2516d
|
@ -142,27 +142,30 @@ class _SearchWidgetState extends State<SearchWidget> {
|
||||||
Future<List<SearchResult>> getSearchResultsForQuery(String query) async {
|
Future<List<SearchResult>> getSearchResultsForQuery(String query) async {
|
||||||
final List<SearchResult> allResults = [];
|
final List<SearchResult> allResults = [];
|
||||||
|
|
||||||
final queryAsIntForYear = int.tryParse(query);
|
if (query.isNotEmpty) {
|
||||||
if (_isYearValid(queryAsIntForYear)) {
|
final queryAsIntForYear = int.tryParse(query);
|
||||||
final yearResult =
|
if (_isYearValid(queryAsIntForYear)) {
|
||||||
await _searchService.getYearSearchResults(queryAsIntForYear);
|
final yearResult =
|
||||||
allResults.add(yearResult); //only one year will be returned
|
await _searchService.getYearSearchResults(queryAsIntForYear);
|
||||||
|
allResults.add(yearResult); //only one year will be returned
|
||||||
|
}
|
||||||
|
|
||||||
|
final holidayResults =
|
||||||
|
await _searchService.getHolidaySearchResults(query);
|
||||||
|
allResults.addAll(holidayResults);
|
||||||
|
|
||||||
|
final collectionResults =
|
||||||
|
await _searchService.getCollectionSearchResults(query);
|
||||||
|
allResults.addAll(collectionResults);
|
||||||
|
|
||||||
|
final locationResults =
|
||||||
|
await _searchService.getLocationSearchResults(query);
|
||||||
|
allResults.addAll(locationResults);
|
||||||
|
|
||||||
|
final monthResults = await _searchService.getMonthSearchResults(query);
|
||||||
|
allResults.addAll(monthResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
final holidayResults = await _searchService.getHolidaySearchResults(query);
|
|
||||||
allResults.addAll(holidayResults);
|
|
||||||
|
|
||||||
final collectionResults =
|
|
||||||
await _searchService.getCollectionSearchResults(query);
|
|
||||||
allResults.addAll(collectionResults);
|
|
||||||
|
|
||||||
final locationResults =
|
|
||||||
await _searchService.getLocationSearchResults(query);
|
|
||||||
allResults.addAll(locationResults);
|
|
||||||
|
|
||||||
final monthResults = await _searchService.getMonthSearchResults(query);
|
|
||||||
allResults.addAll(monthResults);
|
|
||||||
|
|
||||||
return allResults;
|
return allResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue