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 {
|
||||
final List<SearchResult> allResults = [];
|
||||
|
||||
final queryAsIntForYear = int.tryParse(query);
|
||||
if (_isYearValid(queryAsIntForYear)) {
|
||||
final yearResult =
|
||||
await _searchService.getYearSearchResults(queryAsIntForYear);
|
||||
allResults.add(yearResult); //only one year will be returned
|
||||
if (query.isNotEmpty) {
|
||||
final queryAsIntForYear = int.tryParse(query);
|
||||
if (_isYearValid(queryAsIntForYear)) {
|
||||
final yearResult =
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue