I am creating a flutter app which enables a user to select a contact and display the selected contact before navigating back from the list of contact.
class ContactsList extends StatelessWidget {
final List<AppContact> contacts;
Function() reloadContacts;
ContactsList({Key? key, required this.contacts, required this.reloadContacts})
: super(key: key);
@override
Widget build(BuildContext context) {
return Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: contacts.length,
itemBuilder: (context, index) {
AppContact contact = contacts[index];
return ListTile(
onTap: () {
Get.back(result:contact.info.phones!.elementAt(0).value!);
},
title: Text(contact.info.displayName!),
subtitle: Text(contact.info.phones!.length > 0
? contact.info.phones!.elementAt(0).value!
: ''),
leading: ContactAvatar(contact, 36));
},
),
);
}
}