Search code examples
flutterdartlistviewfiltersearchbar

Flutter -- Filtering a List tile data from API in search bar


i have created a list view builder below the search bar. i wanted the generated API data to be filtered and listed in the search bar. iam a beginner and please help

ListView.builder(
shrinkWrap: true,
itemCount: product?.length,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
  return Padding(
    padding: const EdgeInsets.only(left: 15),
    child: Expanded(
      child: ListTile(
          title: Text(product![index].title.toString()),
          leading: CircleAvatar(
            backgroundImage: NetworkImage(
                product![index].image.toString()),
          )),
    ),
  );
},
),

output of the list view builder


Solution

  • You can checkout this example

    https://stackoverflow.com/a/50569613/13078639

    https://www.youtube.com/watch?v=ZHdg2kfKmjI&ab_channel=JohannesMilke

    https://www.youtube.com/watch?v=kX1BJ3XcXcA&ab_channel=InventorCode

    also if you want then you can add a library : Filter List , Search Page