In a code like this:
return ListView(
children: [
for (final String line in lines)
ListTile(
title: Text(line),
onTap: () {
print(line);
},
),
],
);
It would create list tiles with different titles, but when tapping on those, the printed line will be the same.
This can be circumvented by extracting the ListTile() call into a method.