class ContactItem extends StatefulWidget {
final Contact contact;
final bool isAllChecked;
const ContactItem({super.key, required this.contact, required this.isAllChecked});
@override
State<ContactItem> createState() => _ContactItem(this.contact, this.isAllChecked);
}
class _ContactItem extends State<ContactItem> {
Contact contact;
final bool isAllChecked;
bool isChecked = false;
_ContactItem(this.contact, this.isAllChecked);
@override
void initState() {
super.initState();
}
@override
void didUpdateWidget(ContactItem oldWidget) {
print(contact.id);
if (oldWidget.contact != widget.contact) {
contact = widget.contact;
}
super.didUpdateWidget(oldWidget);
}
@override
Widget build(BuildContext context) {
return CheckboxListTile(
value: isChecked,
onChanged: (bool? value) {
setState(() {
isChecked = !isChecked;
});
},
title: Text('${contact.name}'),
subtitle: Text('${contact.id}'),
controlAffinity: ListTileControlAffinity.leading,
);
}
}
class ContactItem extends StatefulWidget {
final Contact contact;
final bool isAllChecked;
const ContactItem({super.key, required this.contact, required this.isAllChecked});
@override
State<ContactItem> createState() => _ContactItem(this.isAllChecked);
}
class _ContactItem extends State<ContactItem> {
final bool isAllChecked;
bool isChecked = false;
_ContactItem(this.isAllChecked);
@override
void initState() {
super.initState();
}
@override
void didUpdateWidget(ContactItem oldWidget) {
print(contact.id);
super.didUpdateWidget(oldWidget);
}
@override
Widget build(BuildContext context) {
return CheckboxListTile(
value: isChecked,
onChanged: (bool? value) {
setState(() {
isChecked = !isChecked;
});
},
title: Text('${widget.contact.name}'),
subtitle: Text('${widget.contact.id}'),
controlAffinity: ListTileControlAffinity.leading,
);
}
}