I am using ListTile in my application. I have an application like below and onTap feature is not triggered here.
I never understood why. I know it's a bad question, but I can't give details because I can't understand why. If there is anything you want me to add, please let me know in the comments.
Widget _buildList(Populations list) {
return Builder(builder: (context) {
return ListTile(
onTap: () => () {
print('object');
},
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(list.animalNo,
style: GoogleFonts.montserrat(
fontWeight: FontWeight.w400,
fontSize: 12,
color: Color(0xFFFFFFFF),
)),
Text(list.group,
style: GoogleFonts.montserrat(
fontWeight: FontWeight.w400,
fontSize: 12,
color:
list.error == true ? Color(0xFFFF0000) : Color(0xFFFFFFFF),
)),
],
),
);
});
}
ListView.builder
Flexible(
child: ListView.separated(
itemCount: populations.length,
itemBuilder: (BuildContext context, int index) {
return _buildList(populations[index]);
},
separatorBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10.0),
child: Divider(
color: Color(0xFF04A1AB),
height: 1,
),
);
},
),
),
CodePudding user response:
You set onTap function wrong, do like this:
onTap:() {
print('object');
},