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> {
final 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);
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,
);
}
}
Widget contactsList() {
return Expanded(
child: Center(
child: isLoaded ? (_filteredContactsList.isNotEmpty ? ListView(
children: [
for (Contact contact in _filteredContactsList)
ContactItem(contact: contact, isAllChecked: isAllChecked,)
// contactItem(contact)
],
) : Text('Контактов нет')) : Text('Идет загрузка...'),
),
);
}