I need the String value of the tapped title from the ListTile
here is my code from the Listviewbuilder:
Expanded(
child: ListView.builder(
itemCount: displayed_add_ingridients_to_meal.length,
itemBuilder: (context, index) => ListTile(
onTap: Ingridients_Selected_x(),
title: Text(displayed_add_ingridients_to_meal[index].Ingridient_title!),
)
)
)
IngridientsSelected_x is a function in which I want to give the searched String value
I guess u have to call some argument in the onTap: method
2
Answers
Just accept the String that you want to pass into your function:
And in your Listview.builder use an anonymous
() =>
function :Or, to make it simpler, without the anonymous function:
Create your function with parameters of String title.
then invoke your function on tap and pass the title value to it.