I wanted to search for a string from a list of local JSON objects. It contains data for each month and the weeks in those months, and looks like this:
[
{
"month": "January",
"weeklyList": [
{
"weekId":1,
"songName" : "some text",
"songDescription" : "some text",
"bookChapter":"some text"
}
]
}
]
I have implemented the methods needed for parsing and populating a list view from it. I have a list of months on the Home screen, as you see on the picture, and use their index to specifically parse the data for the given month when the user clicks on it to navigate to a second screen where the weekly list is populated, which is working fine.
I watched how SearchDelegate works on the Flutter Boring show but I couldn't figure out how to implement it for my JSON. I want to search and show a suggestion list if the entered string is in one of the values in "weeklyList" array. I am confused because I will be searching from the entire JSON without using indexing, on the Home screen. Screenshot image
I understand I should use something like this:
snapshot.data.where((filterString) =>
(filterString.songName.contains(query) || (filterString.songDescription.contains(query))));
but not sure how to go about it. I would appreciate any suggestions for a starting point.
Thank you in advance!