@@ -62,6 +62,7 @@ class SearchResults {
6262 List <SearchResult > searchResults = List <SearchResult >();
6363 List <Promotion > promotions = List <Promotion >();
6464 SearchQuery nextPage;
65+ SearchQuery previousPage;
6566
6667 SearchResults .empty ();
6768
@@ -72,6 +73,12 @@ class SearchResults {
7273 // Deduplicate search result.
7374 this .searchResults = Set <SearchResult >.from (results).toList ();
7475 }
76+
77+ @override
78+ String toString () {
79+ return 'SearchResults{searchResults: $searchResults , nextPage: $nextPage }' ;
80+ }
81+
7582}
7683
7784/// A wrapper class for search request, to make caching search request possible.
@@ -184,6 +191,10 @@ class SearchQuery {
184191 result.nextPage =
185192 this .copyWith (start: search.queries['nextPage' ][0 ].startIndex);
186193 }
194+ if (search.queries['previousPage' ] != null ) {
195+ result.previousPage =
196+ this .copyWith (start: search.queries['previousPage' ][0 ].startIndex);
197+ }
187198 return result;
188199 }
189200
@@ -349,7 +360,7 @@ class _StaticSearchResponse {
349360 {this .assetPath, this .searchType, this .searchResponseJsonString});
350361}
351362
352- /// A fake search data source, that reads data from flutter assests .
363+ /// A fake search data source, that reads data from flutter assets .
353364///
354365/// Choose to do the caching in this class, rather than in the
355366/// [SearchDelegate.showResults] . Because this is controllable by developer,
@@ -409,7 +420,7 @@ class FakeSearchDataSource implements SearchDataSource {
409420 }
410421}
411422
412- /// The search data source that uses Custom Search API.
423+ /// Cached search data source that uses Custom Search API.
413424///
414425/// Choose to do the caching in this class, rather than in the
415426/// [SearchDelegate.showResults] . Because this is controllable by developer,
@@ -445,6 +456,7 @@ class CustomSearchDataSource implements SearchDataSource {
445456 }
446457
447458 final result = await searchQuery.runSearch (this .api);
459+ print ('call search backend' );
448460 _cache.set (searchQuery, result);
449461 return result;
450462 }
0 commit comments