Skip to content

Commit

Permalink
Merge pull request #337 from shashank-lol/main
Browse files Browse the repository at this point in the history
empty state added in search
  • Loading branch information
andoriyaprashant authored Oct 6, 2024
2 parents c63c17a + ee78d46 commit b1ef577
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Binary file added assets/no-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class _HomePageState extends State<HomePage> {
IconButton(
icon: const Icon(Icons.search_sharp),
onPressed: () {
showSearch(context: context, delegate: ProgramSearchDelegate());
showSearch(context: context, delegate: ProgramSearchDelegate(), );
},
),
/*IconButton(
Expand Down Expand Up @@ -662,23 +662,23 @@ class ProgramSearchDelegate extends SearchDelegate<String> {
@override
Widget buildSuggestions(BuildContext context) {
final List<String> suggestionList = query.isEmpty
? []
? ['']
: programs
.where((program) =>
program.title.toLowerCase().contains(query.toLowerCase()))
.map((program) => program.title)
.toList();


return ListView.builder(
return suggestionList.isNotEmpty ? ListView.builder(
itemCount: suggestionList.length,
itemBuilder: (context, index) => ListTile(
itemBuilder: (context, index) => suggestionList[0] == '' ? Container(): ListTile(
title: Text(suggestionList[index]),
onTap: () {
navigateToScreen(context, suggestionList[index]);
},
),
);
) : Image.asset('assets/no-results.png');
}


Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ flutter:
- assets/projects/outreachy/outreachy2023.json
- assets/projects/outreachy/outreachy2024.json
- assets/projects/redox/redox.json
- assets/no-results.png

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
Expand Down

0 comments on commit b1ef577

Please sign in to comment.