File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ class SearchResult {
5050 : result.image.contextLink.hashCode;
5151}
5252
53+ /// A wrapper class to generate search request. To make caching possible.
54+ class SearchRequest {}
55+
5356class Promotion {
5457 final customsearch.Promotion promotion;
5558
Original file line number Diff line number Diff line change @@ -163,12 +163,22 @@ class WebSearchResultCard extends StatelessWidget {
163163 }
164164}
165165
166+ class NoResultCard extends StatelessWidget {
167+ @override
168+ Widget build (BuildContext context) {
169+ return new ListTile (
170+ title: new Text ('No Result.' ),
171+ );
172+ }
173+ }
174+
166175enum SearchType { web, image }
167176enum WebSearchLayout { simple, CSE }
168177
169178class CustomSearchSearchDelegate extends SearchDelegate <SearchResult > {
170179 SearchDataSource dataSource;
171- AutoCompleteDataSource autoCompleteDataSource = CommonEnglishWordAutoCompleteDataSource ();
180+ AutoCompleteDataSource autoCompleteDataSource =
181+ CommonEnglishWordAutoCompleteDataSource ();
172182 SearchType searchType;
173183
174184 CustomSearchSearchDelegate (
@@ -265,6 +275,15 @@ class CustomSearchSearchDelegate extends SearchDelegate<SearchResult> {
265275 return Text ('Awaiting result...' );
266276 case ConnectionState .done:
267277 if (snapshot.hasError) return Text ('Error: ${snapshot .error }' );
278+ if (snapshot.data.searchResults.isEmpty) {
279+ return GridView .count (
280+ crossAxisCount: 1 ,
281+ mainAxisSpacing: 4.0 ,
282+ crossAxisSpacing: 4.0 ,
283+ padding: const EdgeInsets .all (4.0 ),
284+ children: [new NoResultCard ()],
285+ );
286+ }
268287 switch (this .searchType) {
269288 case SearchType .image:
270289 return GridView .count (
You can’t perform that action at this time.
0 commit comments