Guys I am trying to access a variable inside a method and I had to pass this variable to reference method. is that possible?
This is my list builder
return ListView.builder(
itemCount: tasks.length,
itemBuilder: (context, index) {
return TaskTile(
nameOfTheTask: tasks[index].nameOfTheTask,
isChecked: tasks[index].taskStatus,
onTaskCompleted: (checkBoxState) {
setState(() {
tasks[index].updateTaskStatus();
});
},
);
},
);
I want to replace the callback near onTaskCompleted to a reference method.
onTaskChangedReference(checkBoxState) {
setState(() {
tasks[index].taskStatus =
!tasks[indexOfTheTaskTile].taskStatus;
});
}
but I need to use the index variable, is there any way I can do that.